I am new to javascript and jQuery. I am trying to add an attribute on click and remove it on click. I have add and remove class working well but not attribute. My code is below.
HTML below
<label class="label_check" for="fadv">
<input class="lesson" id="fadv" value="acl323" name="fadv" checked="checked" type="checkbox" />Please send me regular updates.
</label>
jQuery below
<script>
function setupLabel() {
if ($('.label_check input').length) {
$('.label_check').each(function(){
$(this).removeClass('c_on');
$(this).removeAttr('pull');
});
$('.label_check input:checked').each(function(){
$(this).parent('label').addClass('c_on');
$(this).attr('pull' , 'on');
});
};
};
$(document).ready(function(){
$('body').addClass('has-js');
$('.label_check, .label_radio').click(function(){
setupLabel();
});
setupLabel();
});
</script>
attribute?