I search a simple/clean way to get every element with the same classes than a selected element.
something like that (not working)
var myElement = $("#elementId");
var listSameClass = $.hasClass(myElement.attr("class"));
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.
I’d suggest, if I understand properly:
This does assume that a single class is present, however.
For elements with multiple classes:
Somehow I’d not realised that you were selecting an element by its
idfirst, in that situation I’d advise you use Matt’s answer, since any correction would essentially turn my answer into a duplicate. Oops.