.reset() form jQuery

Lakukan:


$('#idForm')[0].reset();

nilai pada input didalam form dengan id=’idForm’ di reset.

Source code nya:


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type='text/javascript' src='jquery.js'></script>
<script type='text/javascript'>
$(document).ready(function(){
$('#b_refresh').click(function(){
$('#idForm')[0].reset();
});
});
</script>
</head>
<body>
<form id='idForm'>
Nama: <input type='text' name='nama' value=''><br>
Alamat: <input type='text' name='nama' value=''><br>
No. Telpon: <input type='text' name='nama' value=''><br>
Gaji: <input type='text' name='nama' value=''><br>
<input type='submit' value='Go'>&nbsp;<input type='button' id='b_refresh' value='Reset'>
</form>
</body>
</html>

Demo disini.

Silahkan Komentar ... !

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s