You can use jQuery's each method:

$("*[id^='bgChangerAnchor').each(function () {
        // do some stuff here for each item returned by the match
})'

-----Original Message-----
From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
Behalf Of Edward Ludlow
Sent: Tuesday, April 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 work....is there a reason it
doesn't?

 > $(document).ready(function(){
 >         $("*[id^='bgChangerAnchor').click(function () {
 >                  var id = this.id.replace('bgChangerAnchor', '');
 >                  $("#mainContainer").css("background","url(backgrounds/
 > bg_" + id + ".jpg)");
 >         });
 > });


Thanks, will try that.  Is there no way I can incorporate a simple for loop
so some other stuff can be performed too?

Thanks for the reply.

Ed


Reply via email to