Not exactly, to add to Chris's comment, using:

$("myele").each(function() {
 // do lots of stuff
});

will scope the 'this' keyword to whatever you've selected using $('myele').

So, for example, if I had:

with(document.getElementById("myele")) {
 // myele now part of scope chain, no variable needed
 style.backgroundColor = "#000";
}

I could replace it using the following jQuery:

$("#myele").each(function(){
 // myele now referenced using "this"
 this.style.backgroundColor = "#000";
});

Keep in mind that $(selector).each() will work with all elements that have
been found using a given selector (see http://docs.jquery.com/Core).

Also, this is just my opinion, but using the "with" keyword is usually a bad
idea, as it is difficult to optimize such code and it can cause surprising
behavior when defining functions within such blocks. Instead, just assign
the element to a variable, using jQuery or JavaScript, like:

var myele = $("#myele");
myele.css({backgroundColor:"#000"});

is equivalent to

var myele = document.getElementById("myele");
myele.style.backgroundColor = "#000";

- jake

On 3/8/07, Chris Domigan <[EMAIL PROTECTED]> wrote:

You can use .each().

$("#myId").each(function() {
  // do lots of stuff
});

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to