0

I have a div which on my simple page is retrieved through jQuery's class selector. I want to then attach a mouse over event listener to this div...

 <body>
 <div class="stuffBox">
  <h1>
   stuff
  </h1>
 </div>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
 <script>
  (function(){
      $(".stuffBox").mouseover(function() {
     alert("Here is some stuff");
 });
})

</script>
</body>

And here is the fiddle https://jsfiddle.net/jehanjaleel/xqtp2r3q/

Right now the mouse over is not firing, any idea why?

I would like to reopen this because it works in jsfiddle but not on an actual html page.

AbuMariam
  • 3,282
  • 13
  • 49
  • 82
  • 4
    Open your browser's developer tools. Read the error messages it gives you. **Uncaught ReferenceError: $ is not defined** – Quentin Jan 16 '16 at 16:08
  • @Quentin and Josh, I am still having this problem when I try this code in a standalone html page (although it works in js fiddle). Could you please reopen and copy and paste that code yourself and try? – AbuMariam Jan 18 '16 at 16:20
  • You've got a completely different problem now. It should be a new question, not an edit to the existing one. – Quentin Jan 18 '16 at 16:22

1 Answers1

0
    <body>
 <div class="stuffBox">
  <h1>
  stuff
  </h1>
</div>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script>
(function(){
$(".stuffBox").mouseover(function() {
 alert("Here is some stuff");
});
})

</script>
</body>
Rohit Batham
  • 1,238
  • 1
  • 9
  • 13