jquery selector element with attribute name
In this article, we will tell you how to use the selector element with attribute name in jquery. The “name” attribute is an Equals Selector element. you can be used to select an element by its name. if you are using this type of selector element then it will check the value exactly equal to the specified value in the selector element.
Syntax
1 | $("[attribute='value']") |
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Jquery selector element with attribute name - XpertPhp</title> <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $('input[name="uname"]').val("admin"); }); }); </script> </head> <body> <form> <label>Username: </label> <input type="text" name="uname"> <button type="button">Show Username</button> </form> </body> </html> |
Please follow and like us: