jquery to get next input element

I have a number of checkboxes. Each of them is associated with one input field. When the checkbox is checked, I would like to set the input field is editable, i.e. disabled attribute as false. Otherwise, the input field is readonly. Code for one pair of such checkbox and input field is like below (all these code is included in one section called competencies :

<label class="checkbox span3">
<input id="IT_OS_checkbox" type="checkbox" value="IT_OS" name="competency_checkbox[]">
<div class="controls">
<input id="IT_OS_input" class="input-xxlarge" type="text" name="competency_input[]" disabled="true" placeholder="mots clés séparés par virgule">

So I am trying to use Jquery's on method to fire the event for each checkbox. Code is as below :

$("#competencies").on('change', '.checkbox', function (event) {
    var orig_val = event.target.parent().next('div').find('input').attr('disabled');

For simplicity, I just want to check the selector works fine, however, this code doesn't work. and in firebug, error message is TypeError: event.target.parent is not a function. Can anyone help me figure this out ?


Try this:

$("#competencies").on('change', '.checkbox', function (event) {
    var orig_val = $(event.target).parent().next('div').find('input').attr('disabled');

Just need to wrap the event.target to get the jQuery object.

Need Your Help

Asp.net multiple gridviews, checkboxes in headertemplate select all / deselect all functionality

javascript asp.net c#-4.0

I am using two gridview controls in my aspx page. And I have a column of checkbox in both my controls. I am facilitating the user to select/deselect all checkboxes in my both gridviews by providing a

SQL inner join vs subquery

sql sql-server sql-server-2008

I am working on following queries:

Filling jQuery Progress Bar with results from an external php file

php jquery progress-bar

I am calling two php files throw jQuery and ajax. I have a progress bar at the same page and I need to fill it with respect to the results of those two files. Like for example increase 10% after ev...

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.