Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get nodeType using jquery

Tags:

html

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>
like image 650
Jitender Avatar asked Aug 28 '12 13:08

Jitender


1 Answers

try to access to those properties with

var mm = $('.jj').get(0);
alert(mm.nodeValue);
alert(mm.nodeType)
like image 192
Fabrizio Calderan Avatar answered Sep 28 '22 17:09

Fabrizio Calderan