Click here to Skip to main content
15,887,776 members
Home / Discussions / JavaScript
   

JavaScript

 
QuestionJava Script If Then Statement Pin
Member 978550522-Aug-17 8:38
Member 978550522-Aug-17 8:38 
AnswerRe: Java Script If Then Statement Pin
Richard MacCutchan22-Aug-17 21:23
mveRichard MacCutchan22-Aug-17 21:23 
Questioninput as dtae field,edit and delete buttons.output as a table format in the same page.When we press edit the date will come to the datefield and submit button become as update.when we press update new date has to come in the output.for each and every Pin
Member 1336332215-Aug-17 23:24
Member 1336332215-Aug-17 23:24 
QuestionRe: input as dtae field,edit and delete buttons.output as a table format in the same page.When we press edit the date will come to the datefield and submit button become as update.when we press update new date has to come in the output.for each and e Pin
ZurdoDev22-Aug-17 9:12
professionalZurdoDev22-Aug-17 9:12 
Questiondynamically loaded angular material renders to one md pseudo checkbox regardless of what is my template Pin
Member 1103130414-Aug-17 2:36
Member 1103130414-Aug-17 2:36 
QuestionJavaScript canvas sprite and movement Pin
Muzafferkadir3-Aug-17 15:35
Muzafferkadir3-Aug-17 15:35 
SuggestionRe: JavaScript canvas sprite and movement Pin
Richard Deeming4-Aug-17 1:18
mveRichard Deeming4-Aug-17 1:18 
QuestionMenu not closing when an href is clicked. Pin
NickG227-Jul-17 17:02
NickG227-Jul-17 17:02 
Hello, I have a problem that's been racking my brain for a while now. I have drop-down navigation that I would like closed when I click on an href link. My code works fine if viewed in a desktop but it's in mobile I have problems. If links are clicked that are within my site, the links will be followed, but the menu will not close, however any links that are not on my domain will act fine, the menu will close and the link will be followed. This happens only on mobile. This has been stopping me from opening my site for a while so any help is greatly appreciated.


//JS
JavaScript
<pre>jQuery(document).ready(function($){
	//if you change this breakpoint in the style.css file (or _layout.scss if you use SASS), don't forget to update this value as well
	var MQL = 1170;

	//primary navigation slide-in effect
	if($(window).width() > MQL) {
		var headerHeight = $('.cd-header').height();
		$(window).on('scroll',
		{
	        previousTop: 0
	    }, 
	    function () {
		    var currentTop = $(window).scrollTop();
		    //check if user is scrolling up
		    if (currentTop < this.previousTop ) {
		    	//if scrolling up...
		    	if (currentTop > 0 && $('.cd-header').hasClass('is-fixed')) {
		    		$('.cd-header').addClass('is-visible');
		    	} else {
		    		$('.cd-header').removeClass('is-visible is-fixed');
		    	}
		    } else {
		    	//if scrolling down...
		    	$('.cd-header').removeClass('is-visible');
		    	if( currentTop > headerHeight && !$('.cd-header').hasClass('is-fixed')) $('.cd-header').addClass('is-fixed');
		    }
		    this.previousTop = currentTop;
		});
	}

	//open/close primary navigation
	$('.cd-primary-nav-trigger').on('click', function(){
		$('.cd-menu-icon').toggleClass('is-clicked'); 
		$('.cd-header').toggleClass('menu-is-open');
		
		//in firefox transitions break when parent overflow is changed, so we need to wait for the end of the trasition to give the body an overflow hidden
		if( $('.cd-primary-nav').hasClass('is-visible') ) {
			$('.cd-primary-nav').removeClass('is-visible').one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend',function(){
				$('body').removeClass('overflow-hidden');
			});
		} else {
			$('.cd-primary-nav').addClass('is-visible').one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend',function(){
				$('body').addClass('overflow-hidden');
			});	
		}
	});
});

    $('.cd-primary-nav li a').on('click', function(event){
      var href = $(this).attr('href');
      event.preventDefault;
      $('.cd-menu-icon').removeClass('is-clicked'); 
      $('.cd-header').removeClass('menu-is-open');
      $('.cd-primary-nav').removeClass('is-visible').one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend',function(){
       $('body').removeClass('overflow-hidden');
       document.location = href;
      });
    });


//HTML
HTML
<pre>	<header class="cd-header">
		<div class="cd-logo"><img src="img/cd-logo.svg" alt="Logo"></div>

		<a class="cd-primary-nav-trigger" href="#0">
			Menu
		</a> 
	</header>

	<nav>
		<ul class="cd-primary-nav">
			<li class="cd-label">About us</li>
			<li><a href="http://mysite.com">Home</a></li><pre><!-- This link will not close the menu --><pre>

  • Our services
  • <!-- This link will work fine because it's not on my domain. -->



    QuestionHow browser javascript engine parse and execute javascript Pin
    Mou_kol26-Jul-17 1:36
    Mou_kol26-Jul-17 1:36 
    AnswerRe: How browser javascript engine parse and execute javascript Pin
    Afzaal Ahmad Zeeshan26-Jul-17 1:47
    professionalAfzaal Ahmad Zeeshan26-Jul-17 1:47 
    GeneralRe: How browser javascript engine parse and execute javascript Pin
    Mou_kol3-Aug-17 4:22
    Mou_kol3-Aug-17 4:22 
    Questionjavascript Pin
    arnoldceaser24-Jul-17 1:06
    arnoldceaser24-Jul-17 1:06 
    AnswerRe: javascript Pin
    Richard MacCutchan24-Jul-17 1:52
    mveRichard MacCutchan24-Jul-17 1:52 
    AnswerRe: javascript Pin
    ZurdoDev24-Jul-17 7:07
    professionalZurdoDev24-Jul-17 7:07 
    AnswerRe: javascript Pin
    W Balboos, GHB20-Sep-17 2:06
    W Balboos, GHB20-Sep-17 2:06 
    Questionhow to go to same page again? Pin
    Member 1103130423-Jul-17 22:07
    Member 1103130423-Jul-17 22:07 
    AnswerRe: how to go to same page again? Pin
    Afzaal Ahmad Zeeshan23-Jul-17 23:40
    professionalAfzaal Ahmad Zeeshan23-Jul-17 23:40 
    GeneralRe: how to go to same page again? Pin
    Member 1103130424-Jul-17 0:27
    Member 1103130424-Jul-17 0:27 
    QuestionJavaScript or TypeScript: which one to really dig into? Pin
    Foothill22-Jun-17 10:26
    professionalFoothill22-Jun-17 10:26 
    AnswerRe: JavaScript or TypeScript: which one to really dig into? Pin
    gurdevs8013-Jul-17 20:26
    gurdevs8013-Jul-17 20:26 
    GeneralRe: JavaScript or TypeScript: which one to really dig into? Pin
    Foothill14-Jul-17 4:17
    professionalFoothill14-Jul-17 4:17 
    AnswerRe: JavaScript or TypeScript: which one to really dig into? Pin
    ZurdoDev14-Jul-17 4:50
    professionalZurdoDev14-Jul-17 4:50 
    AnswerRe: JavaScript or TypeScript: which one to really dig into? Pin
    Nathan Minier17-Jul-17 1:41
    professionalNathan Minier17-Jul-17 1:41 
    GeneralRe: JavaScript or TypeScript: which one to really dig into? Pin
    Foothill17-Jul-17 4:13
    professionalFoothill17-Jul-17 4:13 
    AnswerRe: JavaScript or TypeScript: which one to really dig into? Pin
    Kornfeld Eliyahu Peter17-Jul-17 7:58
    professionalKornfeld Eliyahu Peter17-Jul-17 7:58 

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.