In this article, we will tell you how to use the selector element with attribute name in jquery(jquery selector element with attribute name). 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
$("[attribute='value']")
Example
<!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: