I have several span and I want to handle onclick events. First, I want to create some elements on click event. Looks like this:
<div class="priceBox">
Special Price:
<input name="new-price" value="" />
</div>
Then user enters some numer and I want to save the input value to the attribute of span element, which was clicked.
<span name="1" data-price="input value" />
On second click on this span, will the input dissapear.
So far I have managed to create and remove input on click. But by clicking inside the input (when I want to type), makes the input disapear, because this is another click.
Maybe example from JSFiddle will help to understand better what I want. http://jsfiddle.net/0d17qp2L/
EDIT: I've updated @Ryan 's answer and put it to JSFiddle again. It's much better but it still doesn't create data-price attribute with input value.