Give/set attribute value dynamically in jQuery - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:val

Description

Give/set attribute value dynamically in jQuery

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-1.10.1.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){//  www.jav a2 s  .  c  o m
$('#btn').click(function(){
    var text="helloworld";
    $("input[name=newdirpath]").val(text);
});
    });

      </script> 
 </head> 
 <body> 
  <input type="text" value="home" name="newdirpath"> 
  <input type="button" id="btn">  
 </body>
</html>

Related Tutorials