jquery Programming Glossary: consider
jQuery in Greasemonkey 1.0 conflicts with websites using jQuery http://stackoverflow.com/questions/12146445/jquery-in-greasemonkey-1-0-conflicts-with-websites-using-jquery and all conflicts will be resolved. You might also consider switching to Scriptish which has offered superior features and..
In jQuery, how to attach events to dynamic html elements? http://stackoverflow.com/questions/1359018/in-jquery-how-to-attach-events-to-dynamic-html-elements myclass href # test3 a That works with no problem. However consider if the myclass elements were written to the page at some future..
Detecting when a div's height changes using jQuery http://stackoverflow.com/questions/172821/detecting-when-a-divs-height-changes-using-jquery dimensions have changed is less expensive and so you might consider combining the two. Or if you are directly altering the div rather..
:nth-of-type() in jQuery / Sizzle? http://stackoverflow.com/questions/2093355/nth-of-type-in-jquery-sizzle nth child and nth of type and to illustrate the problem consider the following HTML document doctype html html head meta charset..
Selecting element by data attribute http://stackoverflow.com/questions/2487747/selecting-element-by-data-attribute attributes a lot in your jQuery scripts you might want to consider using the HTML5 custom data attributes plugin . This allows..
Can't get correct return value from an jQuery Ajax call http://stackoverflow.com/questions/3537434/cant-get-correct-return-value-from-an-jquery-ajax-call function returns error . return return_data You should consider refactoring your code in such a way that the logic to handle..
Server polling with JavaScript http://stackoverflow.com/questions/3583203/server-polling-with-javascript to the browser in near real time. You can also consider long polling instead of the above to reduce the latency without..
Can I open a dropdownlist using jQuery http://stackoverflow.com/questions/360431/can-i-open-a-dropdownlist-using-jquery multiple selects can be problematic. Perhaps you should consider radio buttons inside a container element which you can expand..
Rotating a Div Element in jQuery http://stackoverflow.com/questions/382591/rotating-a-div-element-in-jquery part of a spin with jQuery's .animate Make sure that you consider the width of your element. If rotate an that has a larger width..
jqGrid does not populate with data http://stackoverflow.com/questions/3912008/jqgrid-does-not-populate-with-data To reduce the size of empty data send from the server consider to use EmitDefaultValue attribute. Moreover I find strange that..
jQuery: live() vs delegate() http://stackoverflow.com/questions/4204316/jquery-live-vs-delegate live share improve this question I never use live I consider the benefits of using delegate to be so substantial as to be..
Jquery live() vs delegate() http://stackoverflow.com/questions/4579117/jquery-live-vs-delegate live share improve this question I never use live I consider the benefits of using delegate to be so substantial as to be..
Choosing Mobile Web HTML5 Framework [closed] http://stackoverflow.com/questions/5063117/choosing-mobile-web-html5-framework team already has experience with ExtJS it might be wise to consider one of these frameworks. Nimblekit This appears to be for iOS.. It is a fairly straight forward framework but I would consider the documentation sparse. Bottom Line 1. jQuery mobile as long..
What are some empirical technical reasons not to use jQuery? [closed] http://stackoverflow.com/questions/5099949/what-are-some-empirical-technical-reasons-not-to-use-jquery or subjective opinions like some other framework is better consider jQuery the straw man for all comparable frameworks in the question...
Where do you include the jQuery library from? Google JSAPI? CDN? http://stackoverflow.com/questions/547384/where-do-you-include-the-jquery-library-from-google-jsapi-cdn Google API's however if that ever changed then I would consider it... First The Google api servers are distributed across the..
.prop() vs .attr() http://stackoverflow.com/questions/5874652/prop-vs-attr of how properties are simpler to deal with than attributes consider a checkbox that is initially checked. Here are two possible..
Cross-browser window resize event - JavaScript / jQuery http://stackoverflow.com/questions/599288/cross-browser-window-resize-event-javascript-jquery do something For the sake of UI responsiveness you might consider using a setTimeout to call your code only after some number..
What is fastest children() or find() in jQuery? http://stackoverflow.com/questions/648004/what-is-fastest-children-or-find-in-jquery cases. Which to use depends on whether you only want to consider the immediate descendants or all nodes below this one in the..
Long Polling/HTTP Streaming General Questions http://stackoverflow.com/questions/7213549/long-polling-http-streaming-general-questions of those methods are certain drawbacks the former one is considered unreliable and sometimes could produce unwanted browser behavior.. per single request connection in a reliable way you should consider using a more advanced technology such as WebSocket which is..
Help understanding jQuery button enable/disable code http://stackoverflow.com/questions/1075651/help-understanding-jquery-button-enable-disable-code Javacript supports both dot notation and bracket notation. Consider opening a new window. window.open This is dot notation in action...
First drop down menu to auto change the options of a second dropdown http://stackoverflow.com/questions/11237900/first-drop-down-menu-to-auto-change-the-options-of-a-second-dropdown connect it using Database yeah it is surely possible. Consider this table CREATE TABLE `contents` `id` INT PRIMARY KEY AUTO_INCREMENT..
Concise way to compare against multiple values http://stackoverflow.com/questions/13737091/concise-way-to-compare-against-multiple-values way to compare against multiple values Consider the following var a 'jesus' if a 'something' a 'nothing' a 'anything'..
Why does jQuery or a DOM method such as `getElementById` not find the element? http://stackoverflow.com/questions/14028959/why-does-jquery-or-a-dom-method-such-as-getelementbyid-not-find-the-element before that DOM element appears in the HTML will fail. Consider the following example script var element document.getElementById..
Can jQuery provide the tag name? http://stackoverflow.com/questions/1532331/can-jquery-provide-the-tag-name .attr doesn't take tag or tagname . Here's what I mean. Consider these elements on a page h1 class rnd First h1 h2 id foo class..
Unable to access the object using `this`. `this` points to `window` object http://stackoverflow.com/questions/15498508/unable-to-access-the-object-using-this-this-points-to-window-object that we're talking about the this pointer inside start . Consider this.start this inside start points to this var funct this.start..
Long polling…really http://stackoverflow.com/questions/15724055/long-polling-really script and the server script again continues the process. Consider a chat application In conventional way you are polling the server..
jQuery Linking vs. Download? http://stackoverflow.com/questions/2093566/jquery-linking-vs-download jQuery library is so that it is cached in a single place. Consider the following scenario User visits site A Site A has jQuery..
What is the simplest jQuery way to have a 'position:fixed' (always at top) div? http://stackoverflow.com/questions/257250/what-is-the-simplest-jquery-way-to-have-a-positionfixed-always-at-top-div scrolls it fires A LOT and can cause performance issues. Consider using it with Ben Alman's debounce throttle plugin to reduce..
functions inside or outside jquery document ready http://stackoverflow.com/questions/2645344/functions-inside-or-outside-jquery-document-ready anyway can be placed outside the document .ready as well. Consider for example a very simple validation function such as function..
Nested jQuery.each() - continue/break http://stackoverflow.com/questions/3267508/nested-jquery-each-continue-break jQuery.each continue break Consider the following code var sentences 'Lorem ipsum dolor sit amet..
jQuery Accordion: IE animation issues http://stackoverflow.com/questions/332448/jquery-accordion-ie-animation-issues CSS emitted by the JQuery Accordion was behaving funky. Consider adding DOCTYPE html PUBLIC W3C DTD XHTML 1.0 Strict EN http..
How can I tell if a particular CSS property is inherited with jQuery? http://stackoverflow.com/questions/5000108/how-can-i-tell-if-a-particular-css-property-is-inherited-with-jquery child relationship which could have simplified matters. Consider this CSS. body color red div div color red and the following..
What's the difference between a jQuery object and a DOM element? Difference between .get() and .index()? http://stackoverflow.com/questions/6942193/whats-the-difference-between-a-jquery-object-and-a-dom-element-difference-betw position of the selected element relative to its siblings. Consider the following HTML ul li 1 li li id second 2 li li 3 li ul And..
What is the reason for var $this = this http://stackoverflow.com/questions/7234282/what-is-the-reason-for-var-this-this does change. jQuery heavily uses the magic this value. Consider this code where you might need something like you are seeing..
How to select elements with jQuery that have a certain value in a data attribute array http://stackoverflow.com/questions/7344361/how-to-select-elements-with-jquery-that-have-a-certain-value-in-a-data-attribute that have a certain value in a data attribute array Consider this snippet of html li id person1 data city Boston New York..
Restart animated GIF as background-image http://stackoverflow.com/questions/7568855/restart-animated-gif-as-background-image to restart an animated GIF used as background image Consider this HTML div id face div id eyes eyes div And this style #eyes.blink..
jQuery/JavaScript JSON object comparison http://stackoverflow.com/questions/8108666/jquery-javascript-json-object-comparison in how it reports the differences within nested objects. Consider this simple example old mum Maria dad Pierre kids Joe Mike Louisa..
Safari: Absolutely positioned DIVs not moving when updated via DOM http://stackoverflow.com/questions/9471038/safari-absolutely-positioned-divs-not-moving-when-updated-via-dom bird3.animate 50 50 milliseconds is a very small delay. Consider optimizing your functions to make the animation perform smoother..
When should I use jQuery deferred's “then” method and when should I use the “pipe” method? http://stackoverflow.com/questions/9583783/when-should-i-use-jquery-deferreds-then-method-and-when-should-i-use-the-pip problem but I hope it illustrates the point. Example 2 Consider Ajax calls. Sometimes you want to initiate one Ajax call after..
jQuery in Greasemonkey 1.0 conflicts with websites using jQuery http://stackoverflow.com/questions/12146445/jquery-in-greasemonkey-1-0-conflicts-with-websites-using-jquery in GM 1.0 It restores the sandbox. The sandbox will be restored and all conflicts will be resolved. You might also consider switching to Scriptish which has offered superior features and performance in the past and does not suffer from this new..
In jQuery, how to attach events to dynamic html elements? http://stackoverflow.com/questions/1359018/in-jquery-how-to-attach-events-to-dynamic-html-elements href # test1 a a class myclass href # test2 a a class myclass href # test3 a That works with no problem. However consider if the myclass elements were written to the page at some future time. For example a id anchor1 href # create link dynamically..
Detecting when a div's height changes using jQuery http://stackoverflow.com/questions/172821/detecting-when-a-divs-height-changes-using-jquery In my experience using this method checking whether the dimensions have changed is less expensive and so you might consider combining the two. Or if you are directly altering the div rather than the div being altered by user input in unpredictable..
:nth-of-type() in jQuery / Sizzle? http://stackoverflow.com/questions/2093355/nth-of-type-in-jquery-sizzle an nth of type selector. To illustrate the difference between nth child and nth of type and to illustrate the problem consider the following HTML document doctype html html head meta charset utf 8 title nth of type in Sizzle jQuery title style body..
Selecting element by data attribute http://stackoverflow.com/questions/2487747/selecting-element-by-data-attribute may not be omitted in this case . Also if you work with data attributes a lot in your jQuery scripts you might want to consider using the HTML5 custom data attributes plugin . This allows you to write even more readable code by using .dataAttr 'foo'..
Can't get correct return value from an jQuery Ajax call http://stackoverflow.com/questions/3537434/cant-get-correct-return-value-from-an-jquery-ajax-call the asynchronous request above. Therefore the getPicsInFolder function returns error . return return_data You should consider refactoring your code in such a way that the logic to handle the JSON object is in the .get callback. Example .get getpics.php..
Server polling with JavaScript http://stackoverflow.com/questions/3583203/server-polling-with-javascript every second or so. Then the server can respond with instructions to the browser in near real time. You can also consider long polling instead of the above to reduce the latency without increasing the frequency of the polls. Quoting Comet Daily..
Can I open a dropdownlist using jQuery http://stackoverflow.com/questions/360431/can-i-open-a-dropdownlist-using-jquery
Rotating a Div Element in jQuery http://stackoverflow.com/questions/382591/rotating-a-div-element-in-jquery you can use a recursive setTimeout You could probably even do part of a spin with jQuery's .animate Make sure that you consider the width of your element. If rotate an that has a larger width than its visible content you'll get funny results . However..
jqGrid does not populate with data http://stackoverflow.com/questions/3912008/jqgrid-does-not-populate-with-data jqGrid. The current JSON data has a lot of data with null value. To reduce the size of empty data send from the server consider to use EmitDefaultValue attribute. Moreover I find strange that you not use parameters like ajaxGridOptions contentType..
jQuery: live() vs delegate() http://stackoverflow.com/questions/4204316/jquery-live-vs-delegate is A LOT bigger than between delegate and .on . jquery live share improve this question I never use live I consider the benefits of using delegate to be so substantial as to be overwhelming. The one benefit of live is that its syntax is..
Jquery live() vs delegate() http://stackoverflow.com/questions/4579117/jquery-live-vs-delegate is A LOT bigger than between delegate and .on . jquery live share improve this question I never use live I consider the benefits of using delegate to be so substantial as to be overwhelming. The one benefit of live is that its syntax is..
Choosing Mobile Web HTML5 Framework [closed] http://stackoverflow.com/questions/5063117/choosing-mobile-web-html5-framework similar to Sencha Touch which is based on ExtJS so if your team already has experience with ExtJS it might be wise to consider one of these frameworks. Nimblekit This appears to be for iOS only not a good thing if you ever decide to expand your application.. interface to native code modules included in the framework. It is a fairly straight forward framework but I would consider the documentation sparse. Bottom Line 1. jQuery mobile as long as your app is not enterprise centric 2. Sencha Touch if..
What are some empirical technical reasons not to use jQuery? [closed] http://stackoverflow.com/questions/5099949/what-are-some-empirical-technical-reasons-not-to-use-jquery jQuery I am not looking for religious or dogmatic arguments or subjective opinions like some other framework is better consider jQuery the straw man for all comparable frameworks in the question. javascript jquery frameworks share improve this question..
Where do you include the jQuery library from? Google JSAPI? CDN? http://stackoverflow.com/questions/547384/where-do-you-include-the-jquery-library-from-google-jsapi-cdn go with the jsapi method since I don't leverage any other Google API's however if that ever changed then I would consider it... First The Google api servers are distributed across the world instead of my single server location Closer servers..
.prop() vs .attr() http://stackoverflow.com/questions/5874652/prop-vs-attr There's a section on element properties . As an example of how properties are simpler to deal with than attributes consider a checkbox that is initially checked. Here are two possible pieces of valid HTML to do this input id cb type checkbox checked..
Cross-browser window resize event - JavaScript / jQuery http://stackoverflow.com/questions/599288/cross-browser-window-resize-event-javascript-jquery jQuery has a built in method for this window .resize function do something For the sake of UI responsiveness you might consider using a setTimeout to call your code only after some number of milliseconds as shown in the following example inspired by..
What is fastest children() or find() in jQuery? http://stackoverflow.com/questions/648004/what-is-fastest-children-or-find-in-jquery experiments there isn't much performance difference in typical cases. Which to use depends on whether you only want to consider the immediate descendants or all nodes below this one in the DOM i.e. choose the appropriate method based on the results..
Long Polling/HTTP Streaming General Questions http://stackoverflow.com/questions/7213549/long-polling-http-streaming-general-questions in a hidden IFRAME or using multipart HTTP responses. Both of those methods are certain drawbacks the former one is considered unreliable and sometimes could produce unwanted browser behavior such as infinite loading indicator and the latter one.. responses . If you'd like to handle multiple responses per single request connection in a reliable way you should consider using a more advanced technology such as WebSocket which is supported by the most current browsers or on any platform that..
Help understanding jQuery button enable/disable code http://stackoverflow.com/questions/1075651/help-understanding-jquery-button-enable-disable-code The first part to understand is symbol resolution. Javacript supports both dot notation and bracket notation. Consider opening a new window. window.open This is dot notation in action. you're telling the interpreter that open can be found..
First drop down menu to auto change the options of a second dropdown http://stackoverflow.com/questions/11237900/first-drop-down-menu-to-auto-change-the-options-of-a-second-dropdown a Database . Working Example Using MySQL Database If you wanna connect it using Database yeah it is surely possible. Consider this table CREATE TABLE `contents` `id` INT PRIMARY KEY AUTO_INCREMENT `name` VARCHAR 255 `parent` INT DEFAULT 0 INSERT..
Concise way to compare against multiple values http://stackoverflow.com/questions/13737091/concise-way-to-compare-against-multiple-values way to compare against multiple values Consider the following var a 'jesus' if a 'something' a 'nothing' a 'anything' a 'everything' alert 'Who cares ' Is there a way to..
Why does jQuery or a DOM method such as `getElementById` not find the element? http://stackoverflow.com/questions/14028959/why-does-jquery-or-a-dom-method-such-as-getelementbyid-not-find-the-element bottom. That means that any call to a DOM element which occurs before that DOM element appears in the HTML will fail. Consider the following example script var element document.getElementById 'my_element' script div id my_element div The div appears..
Can jQuery provide the tag name? http://stackoverflow.com/questions/1532331/can-jquery-provide-the-tag-name find out the tag name of the element as I loop over them but .attr doesn't take tag or tagname . Here's what I mean. Consider these elements on a page h1 class rnd First h1 h2 id foo class rnd Second h2 h3 class rnd Third h3 h4 id bar class rnd Fourth..
Unable to access the object using `this`. `this` points to `window` object http://stackoverflow.com/questions/15498508/unable-to-access-the-object-using-this-this-points-to-window-object this in the first. An important distinction to make is that we're talking about the this pointer inside start . Consider this.start this inside start points to this var funct this.start funct this inside funct start point to window This is..
Long polling…really http://stackoverflow.com/questions/15724055/long-polling-really callback function you again make an ajax call to the same script and the server script again continues the process. Consider a chat application In conventional way you are polling the server say every 2 second's and the server return's even if no..
jQuery Linking vs. Download? http://stackoverflow.com/questions/2093566/jquery-linking-vs-download indefinitely. One of the main points of Google hosting the jQuery library is so that it is cached in a single place. Consider the following scenario User visits site A Site A has jQuery on the same domain so the file is downloaded by the browser..
What is the simplest jQuery way to have a 'position:fixed' (always at top) div? http://stackoverflow.com/questions/257250/what-is-the-simplest-jquery-way-to-have-a-positionfixed-always-at-top-div
functions inside or outside jquery document ready http://stackoverflow.com/questions/2645344/functions-inside-or-outside-jquery-document-ready the DOM document to be loaded or are only called afterwards anyway can be placed outside the document .ready as well. Consider for example a very simple validation function such as function hexvalidate color Validates 3 digit or 6 digit hex color..
Nested jQuery.each() - continue/break http://stackoverflow.com/questions/3267508/nested-jquery-each-continue-break jQuery.each continue break Consider the following code var sentences 'Lorem ipsum dolor sit amet consectetur adipiscing elit.' 'Vivamus aliquet nisl quis velit..
jQuery Accordion: IE animation issues http://stackoverflow.com/questions/332448/jquery-accordion-ie-animation-issues meant that IE 7 was running in quirks mode and the inline CSS emitted by the JQuery Accordion was behaving funky. Consider adding DOCTYPE html PUBLIC W3C DTD XHTML 1.0 Strict EN http www.w3.org TR xhtml1 DTD xhtml1 strict.dtd At the top of your..
How can I tell if a particular CSS property is inherited with jQuery? http://stackoverflow.com/questions/5000108/how-can-i-tell-if-a-particular-css-property-is-inherited-with-jquery are calculated. CSS selectors may not always follow a parent child relationship which could have simplified matters. Consider this CSS. body color red div div color red and the following HTML body div first div div second div body Both first and..
What's the difference between a jQuery object and a DOM element? Difference between .get() and .index()? http://stackoverflow.com/questions/6942193/whats-the-difference-between-a-jquery-object-and-a-dom-element-difference-betw . The index method returns an integer that tells you the position of the selected element relative to its siblings. Consider the following HTML ul li 1 li li id second 2 li li 3 li ul And the following jQuery console.log #second .index Prints 1..
What is the reason for var $this = this http://stackoverflow.com/questions/7234282/what-is-the-reason-for-var-this-this it this way however keeps this from changing whereas this does change. jQuery heavily uses the magic this value. Consider this code where you might need something like you are seeing .fn.doSomethingWithElements function var this this this.each..
How to select elements with jQuery that have a certain value in a data attribute array http://stackoverflow.com/questions/7344361/how-to-select-elements-with-jquery-that-have-a-certain-value-in-a-data-attribute data attribute array is there a way in jQuery to select elements that have a certain value in a data attribute array Consider this snippet of html li id person1 data city Boston New York San Fransisco Person name 1 li li id person2 data city Los..
Restart animated GIF as background-image http://stackoverflow.com/questions/7568855/restart-animated-gif-as-background-image animated GIF as background image Is it possible to restart an animated GIF used as background image Consider this HTML div id face div id eyes eyes div And this style #eyes.blink background image url 'blink.gif' I would like the..
jQuery/JavaScript JSON object comparison http://stackoverflow.com/questions/8108666/jquery-javascript-json-object-comparison but a getDifferences a b function is going to get confusing in how it reports the differences within nested objects. Consider this simple example old mum Maria dad Pierre kids Joe Mike Louisa new mum Julie dad Pierre kids Joe Mary Is the difference..
Safari: Absolutely positioned DIVs not moving when updated via DOM http://stackoverflow.com/questions/9471038/safari-absolutely-positioned-divs-not-moving-when-updated-via-dom function bird2.animate 50 var timer3 setInterval function bird3.animate 50 50 milliseconds is a very small delay. Consider optimizing your functions to make the animation perform smoother for example by replacing jQuery methods with vanilla JavaScript..
When should I use jQuery deferred's “then” method and when should I use the “pipe” method? http://stackoverflow.com/questions/9583783/when-should-i-use-jquery-deferreds-then-method-and-when-should-i-use-the-pip and there are many different maybe better ways to solve this problem but I hope it illustrates the point. Example 2 Consider Ajax calls. Sometimes you want to initiate one Ajax call after a previous one completes. One way is to make the second call..
|