I want to make a div clickable for the link that is contained in that div. I cannot use onclick function since that link is created dynamically. It is a wordpress website.
I tried this method,
$(".pt-cv-ifield").click(function(){
window.location=$(this).find("a").attr("href");
return false;
});
I created this jquery and saved this as clickable.js, and added it to functions.php in my theme file.
function my_theme_scripts() {
wp_enqueue_script( 'clickable', get_template_directory_uri() . '/js/clickable.js', array( 'jquery' ), '1.0.0', true );
}
add_action( 'wp_enqueue_scripts', 'my_theme_scripts' );
Not working. Jquery is a working solution anymore. So past answers are no good.