I’m trying to stop the browser from following certain links, rather I want to unhide some Divs when they are clicked.
I’m having trouble just getting the links to not be followed though.
Here’s what I have:
var titles = $('a.highlight');
jquery.each(titles, function(){
this.click(function(){
return false;
});
});
It seems like the click handler is not being assigned. What am I missing?
Try
Actually, it looks like you might need to use the jQuery constructor on
this:You could also try using parameters on the
eachfunction instead of usingthis:Personally, I would just do
titles.each( ...though. In that instance you can usethisto bind the click handler. I am not sure off the top of my head whatthisbinds to withjQuery.eachOr just calling
clickontitles:That will bind click to every element in
titles. You don’t need to loop through them.