Q: How to add class to parent span of input type radio I have one doubt with jQuery. I have an HTML structure as follow:
<div class="radio" id="uniform-op21">
    <span>
        <input type="radio" value="2" id="op21" name="op11" style="opacity: 0;">
    </span>
</div>

I want to add a class using addClass() of jQuery using id of input type radio that is op21. I am unable to write code. 
when I use the following code: 
$("#op11").parent().addClass("checkbox");

Then it is adding class to <div> instead of <span>. How can I add class to <span> tag using this id ?
update : 
Sorry, Actually the complete code structure is as follow : 
<div style="margin-left:60px;font-size:14px;" class="checked">
    <div class="radio" id="uniform-op11"><span><input type="radio" value="1" id="op11" name="op11" style="opacity: 0;"></span></div>Indira gandhi<br><br>
    <div class="radio" id="uniform-op21"><span><input type="radio" value="2" id="op21" name="op11" style="opacity: 0;"></span></div>Rajendra Singh<br><br>
    <div class="radio" id="uniform-op31"><span><input type="radio" value="3" id="op31" name="op11" style="opacity: 0;"></span></div>Rahul Gandi<br><br>
    <div class="radio" id="uniform-op41"><span><input type="radio" value="4" id="op41" name="op11" style="opacity: 0;"></span></div>Narendra Modi<br><br>
    <div class="radio" id="uniform-zero"><span><input type="radio" value="0" id="zero" name="op21" style="opacity: 0;"></span></div>Narendra Modi<br><br>
    </div>

I want to add the class on the span of input of id zero, When I am using the code 
$("#zero").parent().addClass("checked");

Then It is directly adding the class on the div on the first line. How can I add this, these span tags are added already 

A: You can Try:
$('#op21').closest('span').addClass('checkbox');

Or

$('#op21').parent().addClass('checkbox');

Working Fiddle

A: Simply change $("#op11") to $("#op21"). Other than that, your code is fine.
FIDDLE

A: Your selector is wrong, you want the parent of #op21 not #op11.
$("#op21").parent().addClass("checkbox");

Also you should close your input element with />:
<input type="radio" value="2" id="op21" name="op11" style="opacity: 0;" />


A: It was just your id mistake.Your Jquery is correct:
SEE THIS FIDDLE
$("#op11").parent().addClass("checkbox");

$(document).ready(function(){
alert(document.getElementById('uniform-op21').innerHTML);
});

Note in the alert you can see the class added to the span.

SEE THIS FIDDLE IN WHICH SPAN OF EVERY INPUT IS ADDED WITH class=checkbox

A: Just wrong with your jQuery selector
As your code :
<input id="op21" name="op11">

(short version for more understanding)
Your jQuery :
$("#op11") = <input id="op11">(It's wrong) (your input id is op21)
So correct is :
$("#op21")

Select by id (# = id) (ID Selector)
or
$("input[name='op11']")

Select by attr name (Attribute Equals Selector)

Learn more about selectors

Edited : $('#zero')
