0

i am trying to disable all the controls inside the table row using jquery, but not being able to do so...below is the my html code

<tr id="trChild2">
                    <td>
                        2
                    </td>
                    <td style="height: 30px;">
                        <%:Html.TextBoxFor(m=>m.childName2) %><%--<br />
                        <%: Html.ValidationMessageFor(m=>m.SpouseName,null,new{@Class="field-validation-message"}) %>--%>
                    </td>
                    <td style="height: 30px; text-align: center;">
                        &nbsp;M<%: Html.RadioButtonFor(m=>m.genderIdChild2,1) %>
                        &nbsp;F<%:Html.RadioButtonFor(m=>m.genderIdChild2,2) %>
                    </td>
                    <td style="height: 30px; text-align: center;">
                        <%:Html.TextBoxFor(m=>m.ageChild2,new{Style="width:30px;",maxlength=3}) %><%--<br />
                        <%:Html.ValidationMessageFor(m=>m.SpouseAge,null,new{@Class="field-validation-message"}) %>--%>
                    </td>
                    <td style="height: 30px; text-align: center;">
                        &nbsp;&nbsp;&nbsp;Married<%: Html.RadioButtonFor(m=>m.maritialStatusChild2,1) %>
                        UnMarried<%:Html.RadioButtonFor(m=>m.maritialStatusChild2,2) %>
                    </td>
</tr>

below is my jquery code, which i have used to disabled all the controls inside the table row.

$("#trChild2").find("input,button,textarea").attr("disabled", true);

please note that the #trChild2 is my table row id

kindly let me know what i am doing wrong...

thanks & regards Sameer shaikh

1
  • don't forgot to accept whatever the answer which helps you to solve your problem. Commented Sep 22, 2012 at 12:15

3 Answers 3

2

Put your code in ready block:

$(function(){
    $("#trChild2").find("input,button,textarea").attr("disabled", true); 
});
Sign up to request clarification or add additional context in comments.

Comments

0

Please check http://jsfiddle.net/3QuT4/ it is simple example and it works in the way you specified.

Comments

0

There can be few reasons. May be there can be a jQuery conflict in your code. Use the code below to ignore the conflict.

$.noConflict();/jQuery.noConflict();

Then instead of using $, use jQuery word. Read more

Trying adding a (document).ready function. It allows you to execute the functions you want after the DOM has been loaded.

jQuery(document).ready(function($) {
  jQuery("#trChild2").find("input,button,textarea").attr("disabled", true);
});

If you want to know how the (document).ready works Read more here

Hope this helps you to get your work done.

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.