Reputation: 61
So I have a div class called question_image1
with about four labels inside. My input is wrapped inside of my label <label><input/></label>
, so I didn't use the for
attribute of a label.
I'm trying to select all labels that weren't the ones that were clicked inside of the class.
$(".question_image1").click(function(event) {
$('.question_image1 label').not(event.target).style.opacity = "30%";
});
Is there an obvious problem here? One possibility is that there's a level of div between the question_image1 class and the label. Would that be an issue?
Upvotes: 0
Views: 518
Reputation: 780984
You're trying to use a DOM style
property on a jQuery object. Use the jQuery .css()
method.
$('.question_image1 label').not(event.target).css("opacity", "30%");
But event.target
is will be multiple elements because of event bubbling. So I think you should use
$('.question_image1').not(this).find("label").css("opacity", "30%");
this
will be the element that the event was bound to.
Upvotes: 2