jquery - Javascript set input value when user click button -
im developing chrome extension. want change input value(username) text when user click button. solution not working. need advise. code shown below:
<!doctype html> <html> <head> <meta http-equiv=content-type content=text/html;charset=utf8> <meta http-equiv=content-type content=text/html;charset=windows-1254> <meta http-equiv=content-type content=text/html;charset=x-mac-turkish> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <title></title> <script> $('#target').submit(function() { alert('something'); return false; $('#username').value('test'); }); </script> </head> <body> <form id="target"> <table> <tr> <td>username:</td> <td> <input type="text" id="username" size="20" /> </td> </tr> <tr> <td>password:</td> <td> <input type="password" id="password" /> </td> </tr> <tr> <td></td> <td><input type="button" value="login" id="login" /></td> </tr> </table> </form> </body> </html>
this working fine
$('input#login').click(function() { $('#username').val('test'); return false; });
Comments
Post a Comment