0

I have two Input tag on my page with a button :

   <input id="userName" style="direction: rtl" type="text" value="" runat="server" />
   <input id="txt" style="direction: rtl" type="text" value="" runat="server" />

   <asp:Button ID="Button1" runat="server" Text="" Style="display:none" OnClick="Button1_Click" />

i wrote a script which, [when] i click on Button1, put every thing on userName into txt:

   $('#Button1').click(function ()
        {

            $('#txt').value = $('#userName').value();

       });

but it doesn't work! what is the problem?

user3304614
  • 169
  • 2
  • 9

2 Answers2

1

Use .val(). Try this:

$('#Button1').click(function(){
   $('#txt').val($('#userName').val());
});
Kiran
  • 20,167
  • 11
  • 67
  • 99
1

Try below code where you can call .val() to read from userName and to put value to txt.

$('#Button1').click(function ()
{
   $('#txt').val($('#userName').val());
});
Bhushan Kawadkar
  • 28,279
  • 5
  • 35
  • 57