jQuery object to JavaScript object

前端 未结 5 1019
忘了有多久
忘了有多久 2020-11-30 03:33

If I have a textarea like var txtarea = $(\'textarea\'), how can I set the value to it using the JavaScript property value, and not th

5条回答
  •  心在旅途
    2020-11-30 04:23

    The jQuery .get() will do that for you

    http://api.jquery.com/get/

    Quoted:

    Without a parameter, .get() returns all of the elements:

    alert($('li').get());
    

    With an index specified, .get() will retrieve a single element:

    ($('li').get(0));
    

    ...we can use the array dereferencing operator to get at the list item instead:

    alert($('li')[0]);
    

提交回复
热议问题