开发者

Make a html element appear clickable with JQuery / JS

Is it possible to make an html element appear clickable with JQuery?

开发者_如何学JAVABy appear clickable I mean have the mouse pointer change appearance when the user hovers over the the element.

I dont want to use a tag.


You don't do this with Javascript, you do it with CSS:

.whatever {
    cursor: pointer;
}

You could do the same thing with jQuery if you really wanted, but all you're really doing is setting up the style:

$(".whatever").css("cursor", "pointer");


Use the following code:

jQuery('myelement').css("cursor", "pointer");

This can also be done in pure CSS with cursor:pointer.


You use the CSS cursor property for this. Directly with CSS:

#id { cursor: pointer; }

Or with jQuery using css():

$("#id").css("cursor", "pointer");

Or with Javascript:

document.getElementById("id").style.cursor = "pointer";


Set the style of the element to:

#elementId {
    cursor:pointer;
}

You could do it with jQuery, but not sure why you'd want to? Here 'tis:

$(this).css("cursor", "pointer");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜