Using jQuery to center a DIV on the screen

Using jQuery to center a DIV on the screen

How do I go about setting a

in the center of the screen using jQuery? 1:I like adding functions to jQuery so this function would help:jQuery.fn.center = function () { this.css("position","absolute"); this.css("top", Math.max(

Why would a JavaScript variable start with a dollar sign?

Why would a JavaScript variable start with a dollar sign?

I quite often see JavaScript with variables that start with a dollar sign. When/why would you choose to prefix a variable in this way?(I'm not asking about $('p.foo') syntax that you see in jQuery and others, but normal variables like $name

Does Javascript pass by reference?

Does Javascript pass by reference?

Does Javascript pass by references or pass by values? Here is an example from Javascript: The Good Parts. I am very confused about my parameter for the rectangle function. It is actually undefined, and redefined inside the function. There a

'innerText' works in IE, but not in Firefox

'innerText' works in IE, but not in Firefox

I have some JavaScript code that works in IE containing the following:myElement.innerText = "foo";However, it seems that the 'innerText' property does not work in Firefox. Is there some Firefox equivalent? Or is there a more generic, cros

Pass a PHP string to a JavaScript variable (and escape newlines) [duplicate]

Pass a PHP string to a JavaScript variable (and escape newlines) [duplicate]

This question already has an answer here: How to pass variables and data from PHP to JavaScript? 17 answers What is the easiest way to encode a PHP str

How do I render a partial to a string?

How do I render a partial to a string?

How do I render a partial to a string, so I can include it as part of a JSON response? I have to put it into a JSON response to allow room for a possible error message. The following code gives a 500 server error. If I use just a plain rend

Can multiple directives for one element share an isolated scope?

Can multiple directives for one element share an isolated scope?

Two directives on the same element can not both have isolated scope, but can they both use the same scope isolated from their parent? And can they both use properties bound to the isolated scope?For example, if I have two directives on an

Hide HTML element by id

Hide HTML element by id

Hopefully there's a quick and dirty way to remove the "Ask Question" (or hide it) from a page where I can only add CSS and Javascript: Ask Question I can't hide the nav class because other pag

Console.log IE9 issue

Console.log IE9 issue

I made a simple Task Manager using local.storage and I'm using console.log to set some variables but with that, the entire task app doesn't work in IE.Is there any alternative method of doing this? Here is the fiddle of the working Task Man

Does it make sense to build pure JavaScript based web applications (both client and server side)?

Does it make sense to build pure JavaScript based web applications (both client and server side)?

I've always considered JavaScript as a great addition (or rather, for the last couple of years, as a must have) to the client side of any web application. Even when I started to use Mootools, which takes a big step away from DOM manipulatio

Check if text is in a string

Check if text is in a string

I want to check is some text is in a string for instance i have a stringstr = "car, bycicle, bus"and I have another stringstr2 = "car"I want to check if str2 is in str.I am a newbie in javascript so please bear with me :)Regards 1:if(str

Bypass HTML “required” attribute when submitting [duplicate]

Bypass HTML “required” attribute when submitting [duplicate]

This question already has an answer here: Required attribute HTML5 8 answers I use required for a 1st check before submitting a form.Problem is, that I

How to find out the server IP address (using JavaScript) that the browser is connected to?

How to find out the server IP address (using JavaScript) that the browser is connected to?

Is there any way you can find the IP of the server that the browser is connected to? For e.g. if the browser is accessing http://www.google.com, can we tell in any way what IP it is connected to? This is very useful in cases where Round-rob

Setting a 's display as table-cell

Setting a 's display as table-cell

I'm trying to set a button's display property as table-cell but it doesn't behave like one. Any help would be appreciated. jsFiddle Demo (The demo contains a fixed container height, but I need it to work without it).No fixed sizes Demo.DOM:

Why don't the modern browsers support PUT and DELETE form methods?

Why don't the modern browsers support PUT and DELETE form methods?

I just finished building a RESTful API for one of my latest apps. I also built a simple admin interface scaffolding class that will enumerate resources and build simple forms and tables to edit, create, delete etc.For updating and deleting

Typescript error runtime error: Cannot read property 'prototype' of undefined when extendi

Typescript error runtime error: Cannot read property 'prototype' of undefined when extendi

So I'm getting the above error in the console. It's caused by _super being undefined when it's passed to __extends (in the generated .js).Here's some test code that can be used to reproduce the error://This is the entirety of the file Test.

Returning an Eloquent model as JSON in Laravel 4

Returning an Eloquent model as JSON in Laravel 4

How do you return an Eloquent model to the browser as JSON? What is the difference between the two methods below? Both seems to work.#1:return Response::json($user->toArray());#2:return $user->toJson(); 1:The actual data sent is the same

how to detect a mobile phone in a web application [closed]

how to detect a mobile phone in a web application [closed]

If a web application, how can you figure out the visitor is viewing from a mobile phone?is it also possible figure out the make/model like blackberry versus iphone? 1:You could check their User-Agent string. 2:Scott Hanselman did a po

How do I get a tabbed pane component in JSF 2.0 (Sun Mojarra)

How do I get a tabbed pane component in JSF 2.0 (Sun Mojarra)

I am learning/using JSF 2.0 (Sun Mojarra) now and I want to have a tabbed pane in my webapp (single tabs could named be General, Detail1,Detail2,...).How do I achieve this? I haven't found any documetation for this so far :( 1:Others hav

Client Side Validations and Rails4

Client Side Validations and Rails4

I integrated client side validations with rails4 using the new branches available using the following gemsgem 'simple_form', '~> 3.0.0.rc'gem 'client_side_validations', github: "bcardarella/client_side_validations", :branch => "4-0-beta"gem

How should I create a responsive canvas with createJs to adapt different mobile device's screen

How should I create a responsive canvas with createJs to adapt different mobile device's screen

I want to develop a html5 mobile game. As you know, the screens of mobile devices are different size, so I want to create a responsive canvas so that it can adapt different screen. 1:The simplest way is to resize your canvas with JavaScr

How to force an iFrame to reload once it loads

How to force an iFrame to reload once it loads

I have numerous iframes that load specific content on my pages. Both the parent and iframe are on the same domain. I have a scrollbar inside the iframe that doesn't seem to load correctly in all browsers. But when I refresh the iframe it lo

How to trigger the HTML Select onClick event (activates select dropdown with options)

How to trigger the HTML Select onClick event (activates select dropdown with options)

I want to know how to trigger the onClick event of any select(html combobox element).I tried to do $('#MySelect').click(); using jQuery and tried document.getElementById('MySelect').click(); using pure javascript.But the two don't fire the

How to assign the javascript variable value to php variable [duplicate]

How to assign the javascript variable value to php variable [duplicate]

Possible Duplicate: How to pass JavaScript variables to PHP? I want to assign the javascript variable to php variable $msg = "";$f = new FacebookPost;$f->message = $msg;But it is not working...... 1:Javascript works on the user's comp

Facebook Application Send Friend request using Facebook Api

Facebook Application Send Friend request using Facebook Api

I want to send Facebook friend invitations to some of our friends list without using FBML tags ()I am writing code in ASP.NET using fbServices.How can I send friend requests without using FMBL tags? 1:Friend requests cannot be done throu