Get a specific class using JQuery / JavaScript
I have a div that contains some html elements. They all have a class named
class="fileItem read write"
...
But there may be an element with
class="fileItem read write selected"
...
Now I want to get this element with an additional "selected" tag and edit it. I currently have JQuery
$(".fileItem").click(function(){
// Code
});
which detect a click on one of these files.
Here I want to edit the style tag of the element with the 'selected' tag. So is there something where I can say, get all over the class and choose the option with "selected"?
+3
source to share
7 replies
$(".fileItem").click(function(e) {
e.preventDefault();
$('.selected').css({
'color': 'green'
});
});
+1
source to share