need help to figure out what is the error, it's jQuery code
Question by user1743638
i’m trying to make something like light box for a message with jQuery and CSS
but it doesn’t work!!!
here is jQuery code
$(document).ready(function(e) {
function myFunction(){
$("#overLay").hide();
$("#x").hide();
$("#message").hide();
}
$("#overLay").click( myFunction() );
$("#x").click( myFunction() );
});
Answer by muffel
function myFunction(){
$("#overLay").hide();
$("#x").hide();
$("#message").hide();
}
$(function(){ //run after page is loaded
$("#overLay").click(myFunction);
$("#x").click(myFunction);
});
Answer by Starx
As for the syntactical part, The way you are calling the functions are wrong, call them without the parenthesis
$("#overLay").click( myFunction );
$("#x").click( myFunction );