Jquery - Is there a way to connect buttons?

1

I'm a beginner in programming I'm working with wordpress. On the site I'm helping I have a Slider Revolution with 4 balloons that will serve as buttons. And in the body of the site I have a Portfolio plugin with filters.

I'd like to know if you have a method for that:

  • I can do that when someone clicks on one of the balloons activate the "button" of the filter. (I do not know the class that activates the function).

    • A method to find the function if the first item is not serviced.

Case example:

<div id="1">
<a id="btn1" href="#">Primeiro "botão" sem Função<a>
</div>

<div id="2">
<a id="btn2" href="#">segundo "botão" com Função<a>
</div>

I would like that when I clicked on btn1 I would activate btn2.

Filter - link Silde - link

The two will go on the same page.

    
asked by anonymous 21.02.2017 / 20:43

2 answers

1

See if this helps you:

HTML:

  <button class="btn btn-primary" id="first">1</button>
  <button class="btn btn-primary" id="second">2</button>

JS:

$('#first').click(function (e){
  e.preventDefault();
  $('#second').click(); 
});

$('#second').click(function (e){
  e.preventDefault();
  console.log('Teste')
});

link

    
21.02.2017 / 21:00
1

I do not know if I understand your question right, but from what I saw you want to trigger a function of a button when clicked on another, correct?

I would use jQuery Trigger - link

// quando clica no btn 1
$("#btn1").on("click", function(){
  // Dispara btn2
  $("#btn2").trigger("click");
});

Quando clica em btn 2
$("#btn2").on("click", function(){
  // Faz algo
});
    
21.02.2017 / 21:00