从jQuery对象检索本机DOM元素? [英] Retrieving native DOM elements from jQuery objects?
本文介绍了从jQuery对象检索本机DOM元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
使用jQuery查找元素时,可以通过get函数获取它们:
var regularElement = $('#myElementId')。get(0);
在.each()函数中,this指针指向real元素:
$('input.special')。each(function(){
var type = this。类型;
this.value =exploding balloon;
// etc
})
使用jQuery不会使Javascript不同。 是Javascript,DOM仍然是DOM。
How can I get jQuery to return the native DOM elements it encapsulates?
解决方案
When you find elements with jQuery, you can get them with the "get" function:
var regularElement = $('#myElementId').get(0);
Inside a ".each()" function, the "this" pointer refers to a "real" element:
$('input.special').each(function() {
var type = this.type;
this.value = "exploding balloon";
// etc
})
Using jQuery doesn't make Javascript "different." It is Javascript, and the DOM is still the DOM.
这篇关于从jQuery对象检索本机DOM元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文