-2
    <script src="jQuery/jquery-ui-1.8.21.custom.min.js" type="text/javascript"></script>
    <script src="jQuery/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="jQuery/jquery-1.7.2-vsdoc.js" type="text/javascript"></script>
    <script src="jQuery/jquery-ui-vsdoc.js" type="text/javascript"></script>
    <script>
        $("div").mouseover(function() {
            alert("bla");
        });
    </script>
</head>
<body>
    <div>hello world !!!</div>
</body>

I want the user be able to click on Div and then a message box will appear. y doesnt it work (both on Chrome and IE9) ? using WebMatrix 2.0 !

3 Answers 3

0

In the current version of your code when the code is executed the div DOM elements is not yet available in the DOM .

You need to wrap the handler in the document ready handler. Try this:

$(function(){
   $("div").mouseover(function() {
       alert("bla");
    });
});
0
0

Like @roko-c-buljan says you just can register events after DOM is ready

<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" charset="utf-8">
    jQuery(document).ready(function($){
        $("div").mouseover(function() {
            alert("bla");
        });
    });
</script>
1
  • change mouseover to mouseenter
    – GTSouza
    Jul 13, 2012 at 11:57
0

ok solved the problem.. actually its quite stupid:

i just passed the VSDOC js in top of the regular js

<script src="jQuery/jquery-1.7.2-vsdoc.js" type="text/javascript"></script>
<script src="jQuery/jquery-ui-vsdoc.js" type="text/javascript"></script>
<script src="jQuery/jquery-ui-1.8.21.custom.min.js" type="text/javascript"></script>
<script src="jQuery/jquery-1.7.2.min.js" type="text/javascript"></script>

thank u all :)

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.