0

I just want the cursor to stay a pointer when it passes over the text in my div. Using cs, it works, but using Jquery it reverts to the text selector over text.

This doesn't work...

<style>
#test
{
    height: 300px;
    width: 300px;
    background: blue;
    position:absolute;
    top: 0px;
    left: 0px;
    font-size: 80px;
}

</style>
</head>
<body>
<div id="test">It's not a pointer!</div>
<script src='jquery-1.10.2.min.js'>
</script>
<script>
$(document).ready(function(){
    $("#testjquery").hover(function(){
        $(this).css({'cursor':'hand', 'cursor':'pointer'});
    });
});
</script>

While this works fine...

<style>
#test
{
    height: 300px;
    width: 300px;
    background: blue;
    position:absolute;
    top: 0px;
    left: 0px;
    font-size: 80px;
}
#test:hover
{
    cursor: pointer;
    cursor: hand;
}
</style>
</head>
<body>
<div id="test">It's a pointer!</div>

It seems weird, as I thought jquery simply accessed the css methods. Looking for an explanation, or better yet a solution w/ how to do this in Jquery. Thanks!

Nathan J
  • 195
  • 10

1 Answers1

1

Your div id is test not testjquery

$("#test").hover(function () {
    $(this).css({
        'cursor': 'hand',
        'cursor': 'pointer'
    });
});


Update you can only use
$("#test").hover(function () {
    $(this).css({
        'cursor': 'pointer'
    });
});

Read How can I make the cursor a hand when a user hovers over a list item? as commented by frnhr

Community
  • 1
  • 1
Tushar Gupta - curioustushar
  • 58,085
  • 24
  • 103
  • 107
  • Honest question: do we really need cursor:hand? – frnhr Nov 11 '13 at 01:36
  • 1
    To answer my own question: no :) http://stackoverflow.com/questions/3087975/how-can-i-make-the-cursor-a-hand-when-a-user-hovers-over-a-list-item – frnhr Nov 11 '13 at 01:38