JavaScript this from jQuery this

后端 未结 4 850
既然无缘
既然无缘 2021-01-06 11:24

Is there a way to get JavaScript this from jQuery this?

4条回答
  •  南笙
    南笙 (楼主)
    2021-01-06 12:18

    I don't really understand what you're asking for here, but I'll give it a shot. Firstly, remember that jQuery is just a series of functions written in Javascript. The this keyword is literally the same in "both" contexts.

    Perhaps you want to get the actual DOM element instead of the jQuery object? You can use .get():

    // let's say there's a single paragraph element
    var obj = $('p');   // obj is a jQuery object 
    var dom = obj.get(0);  // dom is a DOM element
    

提交回复
热议问题