How to Close an Infobar on Custom Class?

Have you ever wanted to close an infobar on the click of a button or text?

You can do this by using a custom class and by adding a JS code within your theme’s custom JS option.

Use ‘ib-close-infobar’ class name within a tag for the text you wish to close the infobar on.

Note: You can use any Convert Plus template and follow this method to close an infobar on click of a text.

If you wish to close the infobar on click of a form element, such as a button, you’ll need to use the blank style and enter the code for a button with the class name in the source.

You can refer to this article to edit the HTML of a module.

 

Once you have added the above class name, you will now need to paste the following JS code in the custom JS option of your theme.

// close info bar
        jQuery(".ib-close-infobar").click( function(e){
            e.preventDefault();
            var info_bar = jQuery(this).parents(".cp-info-bar");
            jQuery(document).trigger("cp_close_info_bar",[info_bar]);
        });
Not the solution you are looking for? Check other articles, or open a support ticket.