0
I am using the Wordpress plugin Metaslider for slides, and in it is possible to add links to the images.
I created a button and I need to simulate the click
, as you were clicking on the currently active image in the slider.
I’m using the trigger
to do the simulation, but I can’t do the trigger
work.
<div class="img-slider">
<?php
echo do_shortcode("[metaslider id=135]");
?>
<div class="div-button-box-slider">
<button class="button saiba-mais"> SAIBA MAIS </button>
</div>
</div>
Image of the code generated by the plugin: Script:
<script>
jQuery('.saiba-mais').click(function (e) {
e.preventDefault();
console.log( "You clicked!" );
jQuery(".flex-viewport .slides .flex-active-slide a").trigger("click");
});
Maybe your
click
not within $.ready or onload, try using$(document).on("click", ".saiba-mais", function() {. ..})
... Possible duplicate of: http://answall.com/q/23573/3635– Guilherme Nascimento
It is within $.ready William. The problem is in Rigger, as the function runs to the console.log.
– Flávia Amaral
I voted to close as "too wide" because you didn’t present the HTML structure, but I withdrew the vote to close. I hope my answer will help.
– Guilherme Nascimento
In your code I don’t see those classes
flex.viewport
norslides
. I’d change the jQuery tojQuery(".flex-active-slide a").click();
– Sergio