如何使用jQuery获取nodeType [英] How to get nodeType using jquery
本文介绍了如何使用jQuery获取nodeType的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想获取nodeType,然后将其与文本节点或元素节点进行比较.
I want to get nodeType and then compare it to where it is text node or element node.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="jquery-1.7.2.js"></script>
<script type="text/javascript">
$(function(){
var mm= $('.jj')
alert(mm.nodeValue)
})
</script>
</head>
<body>
<div class="jj">value</div>
</body>
推荐答案
尝试通过以下方式访问这些属性
try to access to those properties with
var mm = $('.jj').get(0);
alert(mm.nodeValue);
alert(mm.nodeType)
这篇关于如何使用jQuery获取nodeType的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文