Why can't I change the CSS of an a
tag with jquery? For instance,
html,
<a href="#">1</a>
<a href="">2</a>
<a href="http://website.com/#/home/about/">3</a>
<a href="http://website.com/home/about/">4</a>
link 1 and 2 are not clickable so I want to remove the pointer cursor.
jquery,
$("a").click(function(e){
if($(this).attr("href") == "#" || $(this).attr("href") == "") {
alert("this is non-clickable");
$(this).css({cursor:"default"});
e.preventDefault();
}
else{
alert($(this).attr("href"));
$(this).css({cursor:"pointer"});
e.preventDefault();
}
});
is it possible?
cursor: pointer;
in the fiddle he has shared :) – Cretic.click
but maybe.mouseenter
ormouseover
. But still yourcss
method is still better. – Define