开发者

Javascript to clear form field on button click

开发者 https://www.devze.com 2023-03-21 04:11 出处:网络
I have a field called \'inputaddress\' which a user types address details into, so they can perform a google map geocode.

I have a field called 'inputaddress' which a user types address details into, so they can perform a google map geocode.

What I would like to do is when the user clicks on the 'sear开发者_运维百科chfortheaddress' button, it will perform the geocode but will then clear the 'inputaddress' field.

Could someone perhaps tell me please how I can clear the field.


document.getElementById("inputaddress").value = '';


Would $('#inputaddress').html(""); or document.getElementById('inputaddress').value="" work?


document.getElementById("inputaddress").value = '';


i am assuming that u id your input address field addr just add this code to the onclick event of your searchforaddress button

document.getElementById('addr').value="";

like this (i am assuming is of ur searchforaddress button is searchforaddress)

    document.getElementById('searchforaddress').onclick=function() {
    document.getElementById('addr').value="";
};
0

精彩评论

暂无评论...
验证码 换一张
取 消