My Jquery console returns the below value. As you could see both $prnt
& $parent
return same value when compared but the if statement return false
console.log($prnt)
//ul#testin.hidden-links
console.log($parent)
//ul#testin.hidden-links
How could I access the id or class name for comparison purpose or how cd I get the below if
statement to return value as True
. Below is the Jquery code.
Jquery
$(document).ready(function(){
$("#cbp-hrmenu > ul > li > a").on('click', function(event){
$item = $(event.currentTarget).parent('li');
var $parent = ($item).parent('ul').get();
var $prnt = $('#cbp-hrmenu > ul').get();
//Below if statement doesn't work only return console
//value within else statement even if if is true
if( $parent === $prnt){
console.log($item.index());
console.log("True");
} else {
console.log("false");
console.log($parent);
console.log($prnt);
}
});
});