1

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?

1 Answer 1

3

The first problem is, you're getting the value of txt only when the page loads, so the variable will always contain an empty value.

The second problem is, you're actually trying to write txt to this.innerText. That's a double mistake, because this in that context is the link clicked, and jQuery has no .innerText (there's .text and .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.

Sign up to request clarification or add additional context in comments.

4 Comments

is there a way you can center the text horizontally and the arrows a little right, like i had it....thanks for the answer
the X's do not stay in the same place, they move with how long the text is...is there a way to fix it?
Hey, how do i keep the X's from moving left due to the length of the div's text?
I guess you should write a separate question about this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.