Reputation: 1197
How do I go about selecting all classes in a class using a jquery selector? You would think something like $(".content .*").click();
would work.
In addition, on click of any class in .content I want to store the class name of the clicked class in a variable.
Upvotes: 0
Views: 876
Reputation: 55750
var $allClassElements = $('[class]', '.content')
should do
Then for further reference of these elements just use the cached variable
$allClassElements.something
Upvotes: 0
Reputation: 254926
Here is a selector for all elements that have at least one class specified
$('.content [class]')
or here is just all elements
$('.content *')
or the better:
$('.content').on('click', '*', function() { //handler here });
Your second question doesn't make much sense and needs to be rephrased
Upvotes: 1
Reputation: 82903
If you are trying to select child elements of ".content" with any class, try this:
$(".content [class]").click
Upvotes: 0