Ahh, I just noticed you'll need to move the semicolon outside the
alert, too. Instead of...
$(this).click(function(){ alert(this.id;) });
do this...
$(this).click(function(){ alert(this.id); });
--Karl
_________________
Karl Swedberg
www.englishrules.com
www.learningjquery.com
On Feb 15, 2007, at 8:20 AM, Karl Swedberg wrote:
Hi Chris,
When you chain jQuery methods to "this", you need to encapsulate
"this" in the jQuery constructor -- $(). Try it this way, and see
if it works:
$(".MyButton").each(function(){
$(this).click(function(){ alert(this.id;) });
});
--Karl
_________________
Karl Swedberg
www.englishrules.com
www.learningjquery.com
On Feb 15, 2007, at 8:14 AM, Mahadewa wrote:
Hi all,
I have a question about .each construct. I have the following
snippet code,
but for some reason it doesn't do what I expected it to do. Have
I missed
something ?
$(".MyButton").each(function(){
this.click(function(){ alert(this.id;) });
});
Thanks for the help,
Chris
--
View this message in context: http://www.nabble.com/Question-
about-.each%28%29-tf3233682.html#a8985143
Sent from the JQuery mailing list archive at Nabble.com.
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/