Jquery to populate input or textarea

前端 未结 4 1883
情书的邮戳
情书的邮戳 2020-12-10 15:57
相关标签:
4条回答
  • 2020-12-10 16:16

    If you want to use pure JavaScript instead of jQuery, try this:

    <form><textarea id="ta"></textarea></form>
    <script type="text/javascript">
        jah = "whatever you want";
        var ta = document.getElementById('ta');
        ta.value = jah;
    </script>
    

    Assigning .value equals jQuery function .val(v);

    0 讨论(0)
  • 2020-12-10 16:17
    $('#myinput').val($('#example').find('p').text());
    

    where 'myinput' is id of your textarea. Paste this line after

    document.getElementById("example").innerHTML=jah;
    
    0 讨论(0)
  • 2020-12-10 16:19

    just like this using jQuery's val method $('#Id').val(jah);

    Where Id is the id of input for textarea. :)

    0 讨论(0)
  • 2020-12-10 16:27

    By using $.val. Assuming #example is a selector pointing to the input field in question, you can use something like this:

    $('#example').val(jah);
    
    0 讨论(0)
提交回复
热议问题