Ok. super confused. I tried to run my code and got multiple type errors, and I am not entirely sure what they even mean, exactly.
What I am trying to do is create a grocery list, with checkboxes, and make it so that when a checkbox is checked, then it adds the css class "text-decoration: line-through" and when it is unchecked, it removes the line through. Help? Thank you :)
Uncaught TypeError: Cannot read property 'replace' of undefined
at Function.camelCase (jquery.min.js:2)
at Function.css (jquery.min.js:2)
at init.<anonymous> (jquery.min.js:2)
at Function.access (jquery.min.js:2)
at init.css (jquery.min.js:2)
at strikeout (check.js:6)
at HTMLButtonElement.onclick (index.html:18)
here is my code:
js file:
function strikeout(){
var checkedbox = document.getElementsByName("grocery").checked;
if (checkedbox == true){
$("checkedbox").css("text-decoration", "line-through");
} else {
$("checkedbox").css();
}
}
html file:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="style.css">
</head>
<body><form>
<h1>Shopping List</h1>
<ul><li><input type="checkbox" name="grocery" value="milk">Milk</li>
<li><input type="checkbox" name="grocery" value="butter">butter</li>
<li><input type="checkbox" name="grocery" value="eggs">eggs</li>
<li><input type="checkbox" name="grocery" value="eggs">cheese</li>
<li><input type="checkbox" name="grocery" value="coffee">coffee</li>
</ul>
<button type="button" onclick="strikeout()">Submit</button>
</form>
<script src="http://ift.tt/VorFZx"></script>
<script src="http://ift.tt/1eUYy5W"></script>
<script src="check.js"></script>
</body>
</html>
Aucun commentaire:
Enregistrer un commentaire