How do I add the title attribute value "not selected" if the checkbox is unchecked?
This is what I tried so far, https://jsfiddle.net/5qakegrz/2/
<input type=checkbox class="fnPress" checked>1
<input type=checkbox class="fnPress">1
<script>
$(function(){
$('input.fnPress:checked').attr("title", "selected");
$('input.fnPress').change(function(){
if($(this).is(":checked")) {
$(this).attr("title", "selected");
} else {
$(this).removeAttr("title");
}
});
});
</script>
$(this).removeAttr("title");to$(this).attr("title", "not selected");