Reputation: 908
I have a function called Designer and I want to return this function if location.hash equals isDesign. I tried the following...
function Designer() {
$("#boxA").fadeIn(700);
$("#boxA span#closeControl").on("click",function(){
$("#builderBox").fadeOut(700);
});
}
if (location.hash = "isDesign") {
return Designer();
}
Instead of the function executing, it assigns the isDesign hash to the url and reloads the page several times. Please, what should I do to correct this. All answers will be appreciated. Thank you.
Upvotes: 1
Views: 8464
Reputation: 4207
Try this:
$(function() {
if (location.hash === "#isDesign") {
Designer();
}
});
function Designer() {
$("#boxA").fadeIn(700);
$("#boxA span#closeControl").on("click",function(){
$("#builderBox").fadeOut(700);
});
}
or just
$(function() {
if (location.hash === "#isDesign") {
$("#boxA").fadeIn(700);
$("#boxA span#closeControl").on("click",function(){
$("#builderBox").fadeOut(700);
});
}
});
Upvotes: 5
Reputation: 11856
Use
if (location.hash == "isDesign") {
return Designer();
}
Single =
is assignment, double ==
is comparison
Upvotes: 0