Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery can't clear specific input with .val('')

I've been looking and looking for an error here as I can't clear the input #keywordsearch when clicking on the reset button in my HTML. However, I can't find anything - can you see an issue?

http://jsfiddle.net/eKWyY/

Here's my JS:

$('#dirreset').click(function() {
            $('#fatform option').each(function(index) {
                $(this).removeAttr("selected");
            });
            $('#keywordsearch').val('');
        });

Thanks for any help, it's driving me a bit mad!

Osu

like image 781
Osu Avatar asked Jan 22 '13 09:01

Osu


1 Answers

Clicking Reset button, the entries are reset to the default values. And asf is your default value, so it wont clear, So change

<input type="reset" name="osu_directory_search_reset" value="Reset" id="dirreset"> 

to

<input type="button" name="osu_directory_search_reset" value="Reset" id="dirreset"> 

Demo: jsFiddle

like image 54
Sudhir Bastakoti Avatar answered Sep 30 '22 22:09

Sudhir Bastakoti