0

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?

3 Answers 3

2
$("#myCheck").click(function() {
  $(".myToggle").find("input, select, textarea")
    .addClass("disabled")
    .attr("disabled", true);
});
Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

1

Your Problem is not clear still u may try this and check if i has got some thing to help?

http://jsfiddle.net/CStTZ/5/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.