If you have multiple images to which you'd like to apply the click functionality, then just change the jQuery code:
<img src="someimage.jpg" class="someClass"> $('.someClass').click(function(){ alert('testing'); }); Same effect, except now every image with that class has that behaviour. -----Original Message----- From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Goofy Sent: Friday, July 20, 2007 12:31 PM To: jQuery (English) Subject: [jQuery] Re: Click to call a fuction? What happens if you already have some 3rd party class on the image like this: <img src="images/Advanced Search Glossy_WIDE.jpg" class="glossy iradius50" alt="" /> If I add an ID the click never gets fired <img src="images/Advanced Search Glossy_WIDE.jpg" id="PanelOpenGlossy" class="glossy iradius50" alt="" /> My other question is this: the ID has to be unique for this approach to work, right? You can't call the same function but have to make a new one. That seems inefficient as I would be repeating the same function for every click, only difference would be there IDs. On Jul 20, 8:23 am, "Andy Matthews" <[EMAIL PROTECTED]> wrote: > Easy to do what you want: > > <img src="someimage.jpg" id="myImage"> > > $('#myImage').click(function(){ > alert('testing'); > > }); > > _____ > > From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] > On Behalf Of Mitchell Waite > Sent: Friday, July 20, 2007 9:21 AM > To: jquery-en@googlegroups.com > Subject: [jQuery] Click to call a fuction? > > Is there a way to call a jQuery function when someone clicks on an > image without making that image a hyperlink. > > If that is the only way is there something you can put in the href to > eliminate the border that hyperlinks make. > > Thanks > > Mitch > > PS I posted this as a question from Goofy last night and no one answered it. > Perhaps now that my status has been so graciously elevated and I am > planning a jQuery for Dummies book, someone might help me. Here is the > previous question > > Why won't this work. It's so simple. I just want to call a function > using the on lick event. I want it to move a div called Panel. > > I set up the function > > function advmode() ( > > $("#Panel").SlideInRight(1000); > > }; > > Then inside a table cell with an image for a button I have this simple > link > > <a href="#Javascript;" > onclick="advmode()"><img src="images/Advanced Search Button Wide_No.png" > width="250" height="25" /> > > I must be missing something really basic because this does not come > close to working. But this does: > > <a href="#Javascript;" > id="PanelButtonOpen2"><img src="images/Advanced Search Button Wide.png" > width="250" height="25" /> > > > $('#PanelButtonOpen2').click(function() { > > $("#Panel").SlideOutRight(1000); > > }); > > Thanks for any aid I am feeling very silly tonight. > > Mitch