Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

clear the old values from textbox using jquery

Tags:

jquery

I am looking for a way to clear the old values from text box when I refresh the page using jquery. I tried this code but it didn't work.

$('#flip_list_search').value = "";
like image 330
sandipon Avatar asked Mar 30 '14 10:03

sandipon


3 Answers

Try this

$("#flip_list_search").val('');
like image 190
Max Langerak Avatar answered Sep 29 '22 14:09

Max Langerak


Use .val()

$('#flip_list_search').val('');

or

$('#flip_list_search')[0].value ='';

.value works with native DOM Object $('#flip_list_search') is jQuery Object

$('#flip_list_search')[0] to get first native DOM Object

like image 29
Tushar Gupta - curioustushar Avatar answered Sep 29 '22 15:09

Tushar Gupta - curioustushar


$("input#flip_list_search","#Your_form_Id").val('');

You can use this. It will be more help to detect your element. Here #Your_form_Id is the id that contains your text box. jQuery search your text box only the #Your_form_Id portion in lieu of whole DOM.

like image 36
Arif Avatar answered Sep 29 '22 16:09

Arif