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!

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

2 Comments

Honest question: do we really need cursor:hand?
To answer my own question: no :) stackoverflow.com/questions/3087975/…

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.