html - Why does the content of my label not change with this jQuery? -
i want change content of label via jquery. i've got code:
html
<input type="checkbox" id="ckbxemp" >employee? <label id="lblssnoritin">bla</label> jquery
$(document).on("change", '[id$=ckbxemp]', function () { var ckd = this.checked; var $lbl = $('[id$=lblssnoritin]'); $lbl.prop("content", ckd ? "ssn" : "itin"); }); ...which can fiddled here
label not have "text" css property (i checked here) , tried it, thought "content" way go - doesn't seem work, either. want "bla" change "ssn" when checkbox checked, , "itin" when unchecked, stays "bla" no matter how many psi apply mouse when checking/unchecking check box. thought whacking hammer, but...it's not mouse.
try using .html() if have html code or .text() plain text instead of .prop("content", ...), this:
$lbl.text(ckd ? "ssn" : "itin");
Comments
Post a Comment