This is part of a lesson on Codecademy. This is a Jquery lesson. I cannot figure out how to append the .item to the .list. They don't explain it on the website and I have been unable to find an answer that I understand.
<!DOCTYPE html>
<html>
<head>
<title>To Do</title>
<link rel="stylesheet" type="text/css" href="stylesheet.css"/>
<script type="text/javascript" src="script.js"></script>
</head>
<body>
<h2>To Do</h2>
<form name="checkListForm">
<input type="text" name="checkListItem"/>
</form>
<div id="button">Add!</div>
<br/>
<div class="list"></div>
</body>
</html>
$(document).ready(function() {
$('#button').click(function() {
var toAdd = $('input[name=checkListItem]').val();
$('div').append('<div class="item">' + toAdd+ '</div>');
});
});
The problem is that I cannot get .item to add into .list. I'm a brand new jQuery user so this is a bit difficult for me to understand. Even after fixing the syntax error it is not adding the correct items.
The website is giving me this error:Oops, try again. Make sure to use .append() to add your .item to your .list!
$('#button').click(function() {
var toAdd = $('input[name=checkListItem]').val();
$('div').append('<div class=".item">') + toAdd+ '</div>'; // Error on this line
});
You are closing function incorrectly. It should be -
$('div').append('<div class="item">' + toAdd+ '</div>');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With