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:

  1. waits before document loaded
  2. removes default event handlers '<- contact us' button.
  3. adds new click event handler
  4. when click on button code checks width of screen
  5. if width < 600 redirect /contact-us
  6. else toggle pop contact form.

Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -