How to get the input text value and set it to span text using jQuery?

2.5k Views Asked by At

I have a form with some input elements like text, dropdown, radiobuttons, etc in my html page. I want to get the entered value in the input text element, selected value or text in the dropdown element (and so on based on input elements type) and set them to text or value of different span elements before submitting the form? I need it as I am trying to implement addthisevent button on my form so that users will be able to save information to their calendar before submitting the form.

2

There are 2 best solutions below

0
AudioBubble On BEST ANSWER

Try to add the Addthisevent button dynamically through jquery or javascript.

1
Katyoshah On

Try this

    <html>
    <head>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script>

   $(document).ready(function(){

   $('.button1').click(function(){

   var text=$('.mytext').val();

   $('.box').html(text);

    });

    });


    </script>

    </head>
     <body>

      <input type="text" class="mytext"></input>

      <div class="button1" id="a1">button1</div>


       <span class="box"></span>


      </body>
      </html>