Reputation: 12512
I need be able to disable form element and add a class "disabled" in all TDs with class="myToggle". Not sure if I'm doing it right:
$("#myCheck").click(function() {
$(".myToggle").addClass("disabled").attr("disabled", true);
});
<td><checkbox id="myCheck"> My checkbox</td>
<td class="myToggle"> My label</td>
<td class="myToggle">
<select>
<option>option
</select>
</td>
Can I combine like this?
Upvotes: 0
Views: 555
Reputation: 15947
$("#myCheck").click(function() {
$(".myToggle").find("input, select, textarea")
.addClass("disabled")
.attr("disabled", true);
});
Upvotes: 2
Reputation: 2324
Your Problem is not clear still u may try this and check if i has got some thing to help?
Upvotes: 1
Reputation:
I believe jQuery has it's own toggle function for elements to show/hide them.
$('.target').toggle();
But what you wrote should work too, since you are trying to operate on a class, and many element can share the same class name at the same time.
Upvotes: 1