html - jQuery onclick multiple elements with the same class -




i have been doing fair bit of searching one, , think on cusp of answer, stuck! basically, looking click 1 element in turn click 2 other elements of same class. when this, 1 element clicked, whereas other isn't:

jquery('.et-pb-arrow-prev').on('click', function(){     jquery('a.et-pb-arrow-prev').click();     console.log('done'); }); 

i able switch elements around element not being clicked, clicked instead of other, can't both other elements click. instead, getting error:

uncaught rangeerror: maximum call stack size exceeded 

i think i'm there, lost now. appreciated.

when trigger click, current element's click handler gets called again reason of call stack error.

jquery('.et-pb-arrow-prev').on('click', function(e, manual) {    if (typeof manual === 'undefined' || manual === false) {      jquery('a.et-pb-arrow-prev').not(this).trigger('click', true);      console.log('triggered', this.textcontent.trim());    } else {      console.log('done', this.textcontent.trim());    }  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <a class="et-pb-arrow-prev" href="#">1</a>  <a class="et-pb-arrow-prev" href="#">2</a>  <a class="et-pb-arrow-prev" href="#">3</a>  <a class="et-pb-arrow-prev" href="#">4</a>





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -