0

Not sure why the open function is not getting called at the onclick even of the button. Any help will be highly useful

<html>
<head>
</head>
<body>
<script>
function open(){
alert('gsfhdgf');
document.getElementById("overlay").style.display="block";
document.getElementById("fade").style.display="block";
}

</script>
<div id="fade" style="display:none">

<div id="overlay" style="display:none">
this is my content
</div>
</div>
<button  onclick="open()">Click Me!</button>
</body>
</html>
2
  • 4
    @1nflktd What would that change? Commented Jul 10, 2014 at 16:36
  • @NiettheDarkAbsol stackoverflow.com/questions/436411/… I'm not saying its the problem here, im just saying its good practice to put it there, but put it anywhere if you want to Commented Jul 10, 2014 at 16:40

1 Answer 1

11

open is already used as a function name (window.open, document.open...)

Name your function something else (preferably something meaningful) and it will work.

Sign up to request clarification or add additional context in comments.

1 Comment

@Niet the Dark Absol : thanks mate.it didn't cross my mind ;).it.working fine now

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.