I have my markup like this. I want that when someone click on the div demo then it will redirect to the second anchor tag link.
<div class="demo">
<div class="social">
<ul>
<li>
<a class="icon"></a>
</li>
<li>
<a href="http://test.com/page" target="_blank" class="icon"></a>
</li>
</ul>
</div>
</div>
So for that I have my jquery like this
jQuery(document).ready(function() {
jQuery(".demo").on('click', function () {
var link = jQuery(this).find('li:last-child').children('a').attr("href");
window.location.href = jQuery(link);
});
});
But this one is showing error in console tab like Uncaught Error: Syntax error, unrecognized expression: with the link . So how to solve this issue?