Categories
Javascript JQuery

Trigger Child Link when Parent is Clicked

Use the code below. Simply change “.parent” to match the parent’s class.

jQuery('.parent').click(function() {

    window.location = jQuery(this).find("a").first().attr("href");

});

 
Also, add a hover effect to the parent element using css so that users know its clickable.

.parent:hover {
    cursor: pointer;
}

Leave a Reply