[jQuery] Re: jQuery within Javascript?

2009-04-08 Thread Edward Ludlow
Michael Geary wrote: The reason your code doesn't work is that you have a single numBackgrounds variable shared throughout all the code. You may increment this in a loop, but then later on when the .click() callback is called, numBackgrounds has already been incremented all the way to 6.

[jQuery] Re: jQuery within Javascript?

2009-04-07 Thread MorningZ
jQuery *is* JavaScript, keep that in mind $(document).ready(function(){ $(*[id^='bgChangerAnchor').click(function () { var id = this.id.replace('bgChangerAnchor', ''); $(#mainContainer).css(background,url(backgrounds/ bg_ + id + .jpg)); }); });

[jQuery] Re: jQuery within Javascript?

2009-04-07 Thread Edward Ludlow
MorningZ wrote: jQuery *is* JavaScript, keep that in mind That's why I was confused why my loop won't workis there a reason it doesn't? $(document).ready(function(){ $(*[id^='bgChangerAnchor').click(function () { var id = this.id.replace('bgChangerAnchor',

[jQuery] Re: jQuery within Javascript?

2009-04-07 Thread Andy Matthews
07, 2009 3:58 PM To: jquery-en@googlegroups.com Subject: [jQuery] Re: jQuery within Javascript? MorningZ wrote: jQuery *is* JavaScript, keep that in mind That's why I was confused why my loop won't workis there a reason it doesn't? $(document).ready(function(){ $(*[id

[jQuery] Re: jQuery within Javascript?

2009-04-07 Thread Mauricio (Maujor) Samy Silva
Is there a missed closing braket and a double quotes after bgChangerAnchor? $(*[id^='bgChangerAnchor').click(function () {

[jQuery] Re: jQuery within Javascript?

2009-04-07 Thread Michael Geary
The reason your code doesn't work is that you have a single numBackgrounds variable shared throughout all the code. You may increment this in a loop, but then later on when the .click() callback is called, numBackgrounds has already been incremented all the way to 6. Also your loop should