Created
December 16, 2018 13:54
-
-
Save kartick14/87ba15eb287a3add44443902a1c05606 to your computer and use it in GitHub Desktop.
jquery open link in second click
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Test jquery</title> | |
</head> | |
<body> | |
<ul class="parentul"> | |
<li class=""><a href="http://www.iamtallmirror.com/">First</a></li> | |
<li class=""><a href="">Second</a></li> | |
<li class=""><a href="">Third</a></li> | |
<li class=""><a href="">Fourth</a></li> | |
<li class=""><a href="">Fifth</a></li> | |
</ul> | |
</body> | |
</html> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> | |
<script type="text/javascript"> | |
jQuery(document).ready(function() { | |
jQuery(".parentul li").each(function(){ | |
jQuery(this).attr('data-click',0); | |
}); | |
jQuery('.parentul li').on('click',function(e){ | |
jQuery('.parentul li').not(this).attr('data-click',0); | |
//if (jQuery(window).width() < 769) { | |
var clickdt = jQuery(this).attr('data-click'); console.log('clickdt: '+clickdt); | |
jQuery(this).attr('data-click',(parseInt(clickdt)+1)); | |
jQuery('.parentul li').css({'background':'none'}); | |
var clickdt1 = jQuery(this).attr('data-click'); | |
if (clickdt1 == 1){ | |
console.log('if-clickdt1: '+clickdt1); | |
jQuery(this).css({'background':'#4fc5d3','color': '#fff'}); | |
e.preventDefault(); | |
} else if(clickdt1 == 2){ | |
console.log('else-clickdt1: '+clickdt1); | |
return true; | |
} | |
//} | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment