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

Deferred initialization of immutable variables

java constructor immutability

I've been using scala's lazy val idiom a lot and I would like to achieve something similar in Java. My main problem is that to construct some value I need some other value which is not known at obj...

WebDriver tracking execution and logging results

java selenium selenium-webdriver webdriver result

We have a keyword driven framework on Selenium-RC. In this framework, keywords, identifiers and data are saved in an XML file and the frameworks will run AUT based on the keywords in XML file.

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.