Menu ▼



Posted By :
avatarmrkraju
Total Views : 1312

Clear all textbox value in the page using jQuery

This example shows you how to clear all textbox values in a page using jQuery. jQuery selector $("input:text") will select all the textboxes in the current document and $("input:text").val("") will clear all the textbox value.

Syntax

$("input:text").val("");

Text1 :

Text2 :

Text3 :

Source Code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Login Page</title>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
    <script type="text/javascript">
        function cleartextboxes() {
            $("input:text").val("");
        }
    </script>
</head>
<body>
    <div>
        Text1 :
        <input type="text" value="Hello" />
        <br />
        <br />
        Text2 :
        <input type="text" value="Example" />
        <br />
        <br />
        Text3 :
        <input type="text" value="jQuery examples" />
        <br />
        <br />
        <input type="button" value="Clear" onclick="cleartextboxes();" />
    </div>
</body>
</html>






comments powered by Disqus


Search dotnetlearners.com