I can select (using jQuery) all the divs in a HTML markup as follows:
$('div')
But I want to exclude a particular div (say having id="myid") from the above selection.
How can I do this using Jquery functions?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Simple:
Using
.not()will remove elements matched by the selector given to it from the set returned by$('div').You can also use the
:not()selector:Both selectors do the same thing, however
:not()is faster, presumably because jQuery’s selector engine Sizzle can optimise it into a native.querySelectorAll()call.