8

How to use jQuery to find a link within the div with a certain class and make it inactive, that is to deprive the property links to her it was impossible to push.

2 Answers 2

16
$("div.someClass").find("a").removeAttr("href");

or if you would rather not get rid of the href attribute:

$("div.someClass a").click(function(e) {
    e.preventDefault();
});
1
  • I suggest the second option. More verbose, but less "hacky", and the document remains valid.
    – mdrg
    Jan 12, 2011 at 11:01
0

Like this:

$("div.classToFind a").click(function() { return false; });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.