In the click callback, check event.target $('div.mydiv').click(function(event) { if ($(event.target).is('.mydiv')) { //this code will not run if you click on an element without .mydiv class } });
- Richard On Thu, Mar 19, 2009 at 5:42 PM, gmoniey <gmon...@gmail.com> wrote: > > Hi...I have div that when clicks on expands (kinda like an > accordion...but multiple divs can be expanded at once) > > The code is something like this: > > $('div').filter('.mydiv').click(function () { > //expand the div here (ajax call) > }); > > Now my problem is that inside this div, there can sometimes be a > link.When the link is clicked, the browser is obviously directed to > the new page, however, the ajax call is still fired off, and the div > attempts to expand (or collapse) before the new page is rendered > > Is it possible to somehow ignore the click when it is on a hyperlink? > I want to reduce the load on the server by removing the unneeded ajax > call. > > Thanks! >