Carlos Carlos - 16 days ago 5
jQuery Question

How to get nodeType using jquery

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>

Answer

try to access to those properties with

var mm = $('.jj').get(0);
alert(mm.nodeValue);
alert(mm.nodeType)
Comments