$(selector).css("cursor", "default") not working in jQuery

Please look for my /* comments */ in my code snippet because that's where the problem is.

I have this <table> with 10 <tr> rows. Each <tr> has a 'custID' attribute. My goal is for the mouse cursor to be a pointer if the user hovers over a <tr> except if the <tr>'s 'custID' attribute is -1, in which case I want the cursor to be the default (or normal), and it's not working.

Here is the code:

<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<!--<script src="../../_scripts/utils.js"></script>-->
<style>
    #gridContents tr {
        background: lightgray;
        cursor: pointer;
    }
</style>
<script>
$(function() {

    /************************************************ 
        THE PROBLEM IS RIGHT HERE!!
        WHY ISN'T THIS WORKING??? 
     ************************************************/
    $("#gridContents tr").mouseenter(function() {
        console.log($(this).attr("custID"));
        if ($(this).attr("custID") === -1) {
            /* THIS NEXT LINE IS NOT TAKING EFFECT, WHY? */
            $(this).css("cursor", "default");
        }
    });
});
</script>
</head>
<body>
<table id="gridContents">
    <tr custID="1"><td>12345</td><td>Doe</td><td>John</td><td>8005551212</td><td>8005551213</td><td>8005551214</td><td>8005551215</td></tr>
    <tr custID="2"><td>12345</td><td>Doe</td><td>John</td><td>8005551212</td><td>8005551213</td><td>8005551214</td><td>8005551215</td></tr>
    <tr custID="3"><td>12345</td><td>Doe</td><td>John</td><td>8005551212</td><td>8005551213</td><td>8005551214</td><td>8005551215</td></tr>
    <tr custID="4"><td>12345</td><td>Doe</td><td>John</td><td>8005551212</td><td>8005551213</td><td>8005551214</td><td>8005551215</td></tr>
    <tr custID="5"><td>12345</td><td>Doe</td><td>John</td><td>8005551212</td><td>8005551213</td><td>8005551214</td><td>8005551215</td></tr>
    <tr custID="6"><td>12345</td><td>Doe</td><td>John</td><td>8005551212</td><td>8005551213</td><td>8005551214</td><td>8005551215</td></tr>
    <tr custID="7"><td>12345</td><td>Doe</td><td>John</td><td>8005551212</td><td>8005551213</td><td>8005551214</td><td>8005551215</td></tr>
    <tr custID="8"><td>12345</td><td>Doe</td><td>John</td><td>8005551212</td><td>8005551213</td><td>8005551214</td><td>8005551215</td></tr>
    <tr custID="9"><td>12345</td><td>Doe</td><td>John</td><td>8005551212</td><td>8005551213</td><td>8005551214</td><td>8005551215</td></tr>
    <tr custID="-1"><td>12345</td><td>Doe</td><td>John</td><td>8005551212</td><td>8005551213</td><td>8005551214</td><td>8005551215</td></tr>
</table>
</body>
</html>

Open in new window

elepilAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
if ($(this).attr("custID") == -1) {

only 2 equals not 3
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
I meant to post the working sample http://jsbin.com/xiwizu/1/edit?html,console,output
Evan CutlerVolunteer Chief Information OfficerCommented:
the comparison in:

$(this).attr("custID") === -1) 

Open in new window


does not come true.  The === operator requires the same type.
(ref. http://www.w3schools.com/js/js_operators.asp)

The CustID is a string and the -1 is a integer.
You have two options:

1. Change -1 to "-1": example:  https://jsfiddle.net/rdd72htL/

2. change the datatype of the left hand value: $(this).attr("custID")  to a numeral.  You can do this by: putting the value inside the Number() function:  

Number($(this).attr("custID") )

Open in new window


This will change the value to a number data type.  Either way, the triple equal (===) is no longer needed at that point.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

elepilAuthor Commented:
You both gave very good variations in the solution, appreciate all of them. Thanks for helping!
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
Congratulations elepil!  You are my 5 millionth point and 3,470th solution

5,000,039Balloons and Confetti
elepilAuthor Commented:
Grats to you! I always knew I brought luck to people. :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.