Changing href for modal pop up with jQuery -
i using joomla!, have button enables form pop out side when clicked. want able change href screen size less 600px instead of using pop redirects user contact page.
i have added jquery:
jquery(function(){ var hrefs = ['contact-us', '#']; jquery(window).on('resize', function() { jquery('.case-study-signoff').prop('href', function() { return hrefs[jquery(window).width() < 600 ? 0 : 1]; }); }).trigger('resize'); }); the previous jquery changes href can see in html nothing happens if click it. can right click , open in new tab takes desired contact page not when clicked.
i've tested on site , seems work:
jquery(document).ready(function() { jquery('.case-study-signoff').off().click(function (e) { e.preventdefault(); if (jquery(window).width() < 600) { window.location = '/contact-us'; } else { pwebcontact177.toggleform(); } }); }); this code following:
- waits before document loaded
- removes default event handlers '<- contact us' button.
- adds new click event handler
- when click on button code checks width of screen
- if width < 600 redirect /contact-us
- else toggle pop contact form.
Comments
Post a Comment