Following is my code. I'm trying to select an element based on tow attributes , one a class using .class selector. and other using a data attribute [data-depth='2'] .
jQuery(document).on('click', ".node [data-depth='2']", function() {
alert("clicked");
})
.node {
height: 30px;
width: 150px;
padding: 5px;
background: #EF4836;
margin: 10px;
cursor:pointer;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="node" data-depth="2">
Click me
</div>
<div class="node" data-depth="3">
Do not Click me
</div>
But the element is not getting selected. What am i doing wrong ?