[Solved] Using JQuery to populate input field with first name and last name on button click [closed]


There are different methods depending on the method used,

For get or set value of an input box you can use :

    $( "cssSelector" ).val();//get
    $( "cssSelector" ).val('new value');//set

See jquery val

For trigger a event like ‘click’ you can :

 $( "#target" ).click(function() {
    alert();
});

or:

    $( "#target" )on('click',function() {
      alert();
    });

For Example :

 $('#clickBtn').on('click',function(){
       $('#result').val( $('#userFname').val()+"."+ $('#userLname').val()+"@"+ $('#userEmail').val());
   });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
   <label for="userFname">First Name :</label>  <input id="userFname" />
    <label for="userLname">Last Name :</label>  <input id="userLname" />
    <label for="userEmail">Email:</label>  <input id="userEmail" />
<button id="clickBtn" >Generate</button>
    <br> <br>
    <label for="result">Email:</label>  <input id="result" />

1

solved Using JQuery to populate input field with first name and last name on button click [closed]