I need to insert a checkbox into a form to change the font weight of text in a div.
My javascript is as follows:
function boldText(checkBox,target) {
if(checkBox.checked){
document.getElementById("lineOne").style.fontWeight = "bold";
}
else {
document.getElementById("lineOne").style.fontWeight = "normal";
}
}
And my html like so:
<input type="checkbox" onclick="boldText(this,textToBold)">
<div id="lineOne">Change text to bold</div>
What is wrong here. I cant seem to get it to work.
remove target it is undefined so it gives an error send id of div in single quate as follow
refer jsfiddle