jQuery Get the Adjecent Element type


I have the following DOM structure and I want to know if the Adjecent Element of the selected checkbox is a “text” type element or not…

		<label><input type="checkbox">AA:</label>
				<li><label><input type="checkbox" id="bb">BB:</label><input type="text"></li>
				<li><label><input type="checkbox">CC:</label><input type="radio"></li>
                               <li><label><input type="checkbox" id="dd">DD:</label><input type="text"></li>

I am using the following jQuery code

$('input[type=checkbox]').bind('click change', function(){

  var getElementType = $(this + ' + input').attr('type');


but getting this error:
uncaught exception: Syntax error, unrecognized expression: [object HTMLInputElement]

In the above DOM structure, it should be for the chekboxes with id “bb” and “dd”,

can someone please help me with this?


From the checkbox, you would want to go up to its parent (the label), and then check the next element.

... = $(this).parent().next().attr('type');

Hey paul

THanks for the solution. It works!