elepil
asked on
$(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:
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>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Grats to you! I always knew I brought luck to people. :)
ASKER