I have made myself a list adder. When you click the link, it adds a div. I am trying to add the current text of the input into the innertext of the div, then append it. After it is added, i want the text to clear in the input. I have tried this http://jsfiddle.net/Hunter4854/hwbcs/2/ but I am stuck, and have no idea how to fix it?
Share
The first problem is, you’re getting the value of
txtonly when the page loads, so the variable will always contain an empty value.The second problem is, you’re actually trying to write
txttothis.innerText. That’s a double mistake, becausethisin that context is the link clicked, and jQuery has no.innerText(there’s.textand.html).Last, to clear the input, just use
$('input').val('');. Passing an empty string to.val()sets the input text to that string.Here’s a working version.