I'm trying to compare these codes to boolean value.
HTML
<a href="#" id="like">
<i class="fa fa-thumbs-o-up fa-fw"></i>
</a>
jQuery
$('#like').on('click', function(event) {
...
var htmlTag = '<i class="fa fa-thumbs-o-up fa-fw"></i>';
var isLike = event.target.closest('#like').innerHTML == htmlTag;
if (isLike) {
console.log('true');
} else {
console.log('false');
}
...
});
But it's going to false, In fact it should be true. Why? Thanks for every answers.
outerHTMLinstead?ielement or use a more specific selector to target it$('.like i')