10Y01
10Y01

Reputation: 13

Prevent anchor behaviour on click on DOM generated element inside anchor

An arrow button for moving a slider ended up inside an anchor element. Now when the button is clicked the anchor link is activated.

The button is part of a dinamically created content on page load by 3rd party slider scripts.

Need to keep the anchor to link to the post. And prevent the anchor from working, only when the button is clicked on.

By the way it´s meant for Wordpress.

Thank you.

var jq=jQuery.noConflict();

jq(document).ready(function(){ 

   jq(document).on("click", 'button.next' , function() {
      jq('a').defaultPrevented();
   });
});

Upvotes: 0

Views: 198

Answers (1)

Mayank Pandeyz
Mayank Pandeyz

Reputation: 26258

Try this:

jq(document).on("click", 'button.next' , function(event) {
      event.preventDefault();
   });

Upvotes: 1

Related Questions