JoshB Posted May 21, 2023 Share Posted May 21, 2023 Is there a way to modify the header button to display different text and perform a different action when clicked, depending on whether the user is on mobile vs not on mobile? On mobile, I would like the text of the header button to read "Call Now" and perform a "Phone" action when clicked. When not on mobile, I would like the text of the header button to read "Contact Us" and perform a "Page" action when clicked, and to bring the user to the "contact" page. I currently have some code that effects the header button, which may or may not be relevant: /* Show button on mobile menu*/ @media screen and (max-width:1024px) { .header-actions-action--cta a { border-radius:5px; padding: .8em .8em !important } .header-actions { display: block !important } .header .header-actions-action--cta { display: block; width: 0% !important; padding-right: 0px; padding-left: 0px } .header-title-nav-wrapper { flex: 100% !important; padding-right: 0px; padding-left: 0px } } Thank you Link to comment
tuanphan Posted May 22, 2023 Share Posted May 22, 2023 What is your site url? Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!) Link to comment
JoshB Posted May 23, 2023 Author Share Posted May 23, 2023 On 5/21/2023 at 10:34 PM, tuanphan said: What is your site url? https://GADogTrainer.com Link to comment
Solution tuanphan Posted May 28, 2023 Solution Share Posted May 28, 2023 On 5/24/2023 at 2:29 AM, JoshB said: https://GADogTrainer.com Add this to Settings > Advanced > Code Injection > Footer <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script> <script> jQuery(document).ready(function($){ if ($(window).width() > 992) { $('div.header-actions-action a.btn').attr('href','/contact'); $("div.header-actions-action a.btn").html(function() { return $(this).html().replace("Call Now: (470)TRAIN-ME", "Contact Us"); }); } }) </script> Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!) Link to comment
JoshB Posted May 31, 2023 Author Share Posted May 31, 2023 Thank you! This worked. tuanphan 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment