Tagged: Button Link
Hi,
I have a button in my site which is only for clicking to addClass with jQuery.
Now every time I click the button the page is going to refresh.
When I set the link manually I want to disable the link wherever on the website.
I read something about it on the forum but I need to add it in my functions file.
Hey (Email address hidden if logged out) ,
Could you please give us a link to your website, we need more context to be able to help you.
Best regards,
Victoria
The only no link I can add to it the button is a #.
See this topic: https://kriesi.at/support/topic/button-element-with-no-link-not-possible/
But if I add # as link it jumps to the top of the page when I click the button but I don’t want to.
When I set the link to manually it refreshes the page but I dont’ want to.
See the button ‘Meer info +’ on page in private content.
Hi (Email address hidden if logged out) ,
Can you please post the JavaScript code that you use to make this button?
Best regards,
Victoria
It is a normal button from the avia builder with class ‘.meer_info_portfolio’
This is the code in my functions:
function script_meerinfo(){
?>
<script>
jQuery(document).ready(function(){
jQuery( ".meer_info_portfolio .avia-button" ).click(function() {
jQuery( ".infoblokportfolio" ).toggleClass( "tonen" );
});
});
</script>
<?php
}
add_action('wp_footer', 'script_meerinfo');
I already found the solution:
Added this code to my document ready function:
jQuery(".meer_info_portfolio a").click(function(event){
event.preventDefault();
});