0

I have tried numerous javascript/jquery codes to get my form (after 'submit' is clicked) to reset the screen zoom/viewport. My page does NOT reload on 'submit' but merely loads the 'submit successful' message. Nothing I've tried so far has worked. I am using the below code

jQuery(document).ready(function($){ 
    $('#form-id').submit(function(event) { 
      var viewportmeta = document.querySelector('meta[name="viewport"]'); 
      if (viewportmeta) { 
          viewportmeta.setAttribute('content', 'width=device-width, maximum-scale=1.0, initial-scale=1.0');
      } 
    }); 
});

I have tried different variations of this but I'm no expert. Do I need to put 'form' before the form id?

$('form#form-id')

Am I messing up the syntax between javascript and jQuery? Typos? Any help would be greatly appreciated :)

JaxJames
  • 81
  • 1
  • 11
  • Couple of duplicate posts from stackoverflow. http://stackoverflow.com/questions/25523284/change-viewport-meta-tag-with-jquery and http://stackoverflow.com/questions/3588628/can-i-change-the-viewport-meta-tag-in-mobile-safari-on-the-fly – CodeMonkey Apr 12 '16 at 02:07
  • Just have a look if the page reload or refresh after your form submits. It tends to happens and any Javascript made changes will be revert back to normal. – CodeMonkey Apr 12 '16 at 02:11
  • No, the page doesn't refresh or reload. It just shows the 'submit successful' message in place of the form. Those posts you've suggested work when the page is reloaded. This is not helpful in my case – JaxJames Apr 12 '16 at 02:33

0 Answers0