x [0] .html()或$(x)[0]不是jQuery函数 [英] x[0].html() or $(x)[0] is not a function jQuery
本文介绍了x [0] .html()或$(x)[0]不是jQuery函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有4个HTML DOM元素:
I have 4 HTML DOM elements:
<div data-equipment-type="addon" style="display: inline-block;">Universal Plug Adaptor</div>
<div data-equipment-type="addon" style="display: inline-block;">WiFi Access</div>
<div data-equipment-type="addon" style="display: inline-block;">LAN Cable</div>
<div data-equipment-type="addon" style="display: inline-block;">Mouse</div>
我使用jQuery查询了这些DOM元素:
I queried these DOM elements using jQuery:
var x = jQuery('div[data-equipment-type="addon"')
然后我想获取x中每个DOM元素存储的html()值.预期输出:
then I want to get the html() values of each DOM element store in x. Expected Output:
Universal Plug Adaptor
WiFi Access
LAN Cable
Mouse
但是,以下功能不起作用.
However, the following functions does not work.
x[0].html()
$(x)[0].html()
,但以下内容返回html元素:
but the following returns the html element:
x[0] //output is <div data-equipment-type="addon" style="display: inline-block;">Universal Plug Adaptor </div>
$(x)[0] //output is <div data-equipment-type="addon" style="display: inline-block;">Universal Plug Adaptor </div>
推荐答案
x
现在是DOM元素的jQuery集合(数组).
x
is now a jQuery collection (Array) of DOM elements.
x.eq(0).html()
或
$(x[0]).html()
或在JS
x[0].innerHTML
将为您提供所需的
这篇关于x [0] .html()或$(x)[0]不是jQuery函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文