scythargon
scythargon

Reputation: 3491

is(':hover') works on jsfiddle but not from local file

This example works, but if i create local file like this:

<script src="jquery-big.js"></script>
<div id="test">
    <div id="hello">click</div>
    <div id="no-hello">click</div>
</div>

<script>
$('#test').click(function() {
    if ($('#hello').is(':hover')) {
        $('#hello').html($('#hello').html()+' strange ');
    }
});
</script>

(removed all utf-8 bug-symbols from jsfiddle) - nothing works, and no errors in console. checked in Google Chrome 19.0.1084.46.

Upvotes: 0

Views: 175

Answers (1)

Hacker Wins
Hacker Wins

Reputation: 1289

try like this~

<!DOCTYPE HTML>
<html lang="en-US">
<head>
    <meta charset="UTF-8">
    <title>question</title>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <script type="text/javascript">
        //document ready script here
        $(document).ready(function() {
            $('#test').click(function() {
                if ($('#hello').is(':hover')) {
                    $('#hello').html($('#hello').html()+' strange ');
                }
            });
        });
    </script>
</head>
<body>
    <!-- element below-->
    <div id="test">
        <div id="hello">click</div>
        <div id="no-hello">click</div>
    </div>
</body>
</html>

Upvotes: 1

Related Questions