开发者

Javascript to clear form field on button click

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜