Reputation: 39
How to create if I have in my url:
mysite.com/#newgoal
, my modalbox is displayed?
Currently is displayed if I click button with id="newGoalButton"
.
I need both options at once.
HTML:
<a href="#newgoal" id="newGoalButton">New Goal</a>
JS:
$(document).ready(function(){
$('#newGoalButton').click(function() {
$(".fullWhite").fadeIn(100);
$(".modal").fadeIn(200);
});
$('.modal .iks').click(function() {
$(".fullWhite").fadeOut(200);
$(".modal").fadeOut(100);
});
});
Upvotes: 0
Views: 48
Reputation: 26
You could use:
<script>
$(document).ready(function(){
var url = window.location.href;
if (url.indexOf("#newgoal") != -1){
// display modalbox
}
});
</script>
Upvotes: 1
Reputation: 66560
You can use jQuery hashchange plugin :
$(window).hashchange(function() {
if (location.hash === '#newgoal') {
$(".fullWhite").fadeIn(100);
$(".modal").fadeIn(200);
}
});
And I think you will not need $('#newGoalButton').click
if you use this:
Upvotes: 0