Reputation: 179
I have the following code does not work when I click on reset.
For some strange reason when does the process of generating the values in the "results" field and I click on "reset" does not clear the field "enter".
EXAMPLE: http://jsfiddle.net/Ljsp6Lv6/1/
HTML:
<h3>Enter:</h3>
<textarea value="" id="enter"></textarea>
<div id="hide">
<h3>Result:</h3>
<textarea class="disable" id="result"></textarea>
<br />
<input type="reset" value="Reset" class="button reset" />
</div>
JS:
$('#enter').keyup(function () {
var eachLine = $(this).val().split('\n');
var result='';
console.log(eachLine);
for(var i=0;i<eachLine.length;i++){
var url = 'http://www.domain.com/myimages/' + eachLine[i] + '/' + eachLine[i] + '_small.jpg';
result = result + url + '\n';
}
$('#hide').show();
$('#result').html(result);
});
Upvotes: 0
Views: 703
Reputation: 318212
You'll need a form element to make reset
work, and that's the answer, wrap everything you want to reset in a form element.
If you want to hide the other textarea as well, add some more jQuery
$('.reset').on('click', function() {
$('#enter').trigger('keyup');
$('#hide').hide();
});
Upvotes: 2