disable all input tags of parentNode -jquery

I need to disable all input tags of parent node of current object

Scenario is like below

question with options

 <div class="question_title"> 
      question 1

     <div class="answers"> 
      <div class="optionsa">
       [radiobutton] opt1
     </div>
     <div class="optionsa">
       [radiobutton] opt2
     </div>
    <div class="optionsa">
       [radiobutton] opt3
    </div>
  </div>  
 </div> 

 <div class="question_title"> 
      question 2

     <div class="answers"> 
      <div class="optionsa">
       [radiobutton] opt1
     </div>
     <div class="optionsa">
       [radiobutton] opt2
     </div>
    <div class="optionsa">
       [radiobutton] opt3
    </div>
  </div>  
 </div>         

now whenever i choose one option of one question it should disable all other options

i did the following

<script language="javascript">
    $(document).ready(function(){
          $(".optionsa").click(function(){
                $(this).parent().parent().children().attr('disabled',true);

          });
});
  </script>

but it is not working, anything that i missed here?

Answers


Try to use .closest() along with .find() in this context,

 $(".optionsa").click(function(){
     $(this).closest('.question_title').find(':radio').prop('disabled',true);
 });

Need Your Help

Will SQL Server Service Broker be supported in SQL Azure in future?

sql-server sql-server-2008 sql-azure service-broker

I found that SQL Server Service Broker is not supported in SQL Azure. Service Broker is a very attractive choice for our event notification needs. But before committing to it I wanted to make sure it

Starting a SKProductsRequest gives - invalid selector error a moment later. LoadMicroPaymentsProductsOperation error

iphone objective-c xcode in-app-purchase storekit

I'm fetching a list of identifiers from my server, then passing them off in a products request to Apple. Here's my code, and below is the error I'm getting.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.