如果我有一个变量和一个 jQuery,我如何执行查询并获取第一个结果 DOM 元素本身(如果有)?
var $myQuery = $(...)
var domNode = $.myQuery<what to write here?> // and what if the query has not results?
最佳答案
这将返回 native DOM 对象
var domNode = $myQuery[0] //undefined if there is not any element.
或
var domNode = $myQuery.get(0) // Identical to above, only slower (according to doc).
资源
关于javascript - 给定一个 jQuery,如何获取第一个结果元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48936268/