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>
Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592
user3478137
  • 9
  • 1
  • 5
  • 4
    @1nflktd What would that change? – Niet the Dark Absol Jul 10 '14 at 16:36
  • @NiettheDarkAbsol http://stackoverflow.com/questions/436411/where-is-the-best-place-to-put-script-tags-in-html-markup 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 – hlscalon Jul 10 '14 at 16:40

1 Answers1

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.

Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592