Can someone please explain in what cases the following syntax can be used and how does this work?  (function($) {     $.fn.hoverIntent = function(f,g) {     }; })(jQuery);   Thanks!
9076
In javascript, when would you want to use this:  (function(){     //Bunch of code... })();   over this:  //Bunch of code...
52702
As far as I can tell, these two pieces of javascript behave the same way:  Option A:  function myTimeoutFunction() {     doStuff();     setTimeout(myTimeoutFunction, 1000); }  myTimeoutFunction();   Option B:  function myTimeoutFunction() {     doStuff(); }  myTimeoutFunction(); setInterval(myTimeoutFunction, 1000);   Is there any difference between using  and ?
5575
I have the name of a function in JavaScript as a string. How do I convert that into a function pointer so I can call it later?  Depending on the circumstances, I may need to pass various arguments into the method too.  Some of the functions may take the form of namespace.namespace.function(args[...]).
58463
Does anyone know of an easy way to escape HTML from strings in ?  I need to be able to pass an arbitrary string and have it properly escaped for display in an HTML page (preventing JavaScript/HTML injection attacks).  I'm sure it's possible to extend jQuery to do this, but I don't know enough about the framework at the moment to accomplish this.
10734
I'm using jQuery to wire up some mouseover effects on elements that are inside an UpdatePanel. The events are bound in $(document).ready . For example:  $(function() {         $('div._Foo').bind("mouseover", function(e) {         // Do something exciting     });     });   Of course, this works fine the first time the page is loaded, but when the UpdatePanel does a partial page update, it's not run and the mouseover effects don't work any more inside the UpdatePanel.   What's the recommended approach for wiring stuff up in jQuery not only on the first page load, but every time an UpdatePanel fires a partial page update? Should I be using the ASP.NET ajax lifecycle instead of $(document).ready?
28108
If i do jQuery(expr).change( function), then I can get an event function to fire when the user makes a change to the value.  Is it possible to get this to fire if it's changed programatically, ie if I call jQuery(expr).val("moo").  or if some Plain old JavaScript changes it's value?  Thanks for any help.
9464
I was having some thought about what would be the syntax to make the end point evaluation of derivatives or integrals. Such as making the | with the two end points of evaluation on the top an bottom of the line. Any suggestions would be wonderful.
115050
What is the correct output (meaning correct by the ECMA standard) of the following program?  function nl(x) { document.write(x + "&lt;br&gt;"); } nl(Function.prototype); nl(Function.prototype.prototype); nl(Function.prototype.prototype == Object.prototype); nl(Function.prototype.prototype.prototype);   Chrome and IE6 agree in saying:   function Empty() {} null for Chrome / undefined for IE6 false   and then crashing.  Mozilla outputs:  function () { } [object Object] false undefined   Are either of these correct? It seems that the Mozilla one does better, but that the best output is  function () { } [object Object] true undefined
19582
If I set a CSS value on a specific element using:  $('#element').css('background-color', '#ccc');   I want to be able to unset that element-specific value and use the cascaded value, along the lines of:  $('#element').css('background-color', null);   But that syntax doesn't seem to work – is this possible using another syntax?  Edit: The value isn't inherited from the parent element – the original values comes from an element-level selector. Sorry for any confusion!
97201
I have something like this:  &lt;div class="content"&gt;     &lt;a href="#"&gt;A&lt;/a&gt; &lt;/div&gt; &lt;div class="content"&gt;     &lt;a href="#"&gt;B&lt;/a&gt; &lt;/div&gt; &lt;div class="content"&gt;     &lt;a href="#"&gt;C&lt;/a&gt; &lt;/div&gt;   When one of these links is clicked, I want to perform the .hide() function on the links that are not clicked. I understand jQuery has the :not selector, but I can't figure out how to use it in this case because it is necessary that I select the links using $(".content a")  I want to do something like  $(".content a").click(function() {     $(".content a:not(this)").hide("slow"); });   but I can't figure out how to use the :not selector properly in this case.
372
What is the difference between the search() and match() functions in the ?  I've read the  (), but I never seem to remember it.  I keep having to look it up and re-learn it.  I'm hoping that someone will answer it clearly with examples so that (perhaps) it will stick in my head.  Or at least I'll have a better place to return with my question and it will take less time to re-learn it.
5353
Is there a canonical way to set up a JS onHover event with the existing onmouseover, onmouseout and some kind of timers?  Or just any method to fire an arbitrary function if and only if user has hovered over element for certain amount of time.
3057
I need to change an element's ID using jQuery.    Apparently these don't work:  jQuery(this).prev("li").attr("id")="newid" jQuery(this).prev("li")="newid"   I found out that I can make it happen with the following code:  jQuery(this).prev("li")show(function() {     this.id="newid"; });   But that doesn't seem right to me. There must be a better way, no? Also, in case there isn't, what other method can I use instead of show/hide or other effects? Obviously I don't want to show/hide or affect the element every time, just to change its ID.  (Yep, I'm a jQuery newbie.)  Edit I can't use classes in this case, I must use IDs.
8344
I'm working with a bit of html and Javascript code that I've taken over from someone else. The page reloads a table of data (via an asynchronous request) every ten seconds, and then re-builds the table using some DOM code. The code in question looks something like this:  var blah = xmlres.getElementsByTagName('blah'); for(var i = 0; i &lt; blah.length; i++) {     var td = document.createElement('td');     var select = document.createElement('select');     select.setAttribute("...", "...");     select.onchange = function() {         onStatusChanged(select, callid, anotherid);     };     td.appendChild(select); }   When the onchange event is fired for a &lt;select&gt; element however, it seems like the same values are being passed to the onStatusChanged() method for every &lt;select&gt; in the table (I've verified that in each iteration of the loop, callid and anotherid are being given new, distinct values).   I suspect this is occuring because of the nature of how I am setting the event handler, with the select.onchange = function() syntax. If I understand how this is working correctly, this syntax sets a closure for the onchange event to be a function which refers to these two references, which end up having a final value of whatever they are set to on the last iteration of the loop. When the event fires, the value referenced by callid and anotherid is the value set in the last iteration, not the value set at the individual iteration.  Is there a way that I can copy the value of the parameters I am passing to onStatusChanged()?  I've changed the title to better reflect the question and the accepted answer.
29305
What does it mean to extend a function? Can someone please give an example?  Thanks in advance!
85789
I'm trying to use this code to replace spaces with _, it works for the first space in the string but all the other instances of spaces remain unchanged. Anybody know why?  function updateKey() {     var key=$("#title").val();     key=key.replace(" ","_");     $("#url_key").val(key); }
73056
Suppose I want to integrate $f(x)+g(x)$. Can this be written as $\int f(x)+g(x)\, dx$ or are brackets necessary, i.e.  $\int \left(f(x)+g(x)\right) \,dx$?