当前位置: 动力学知识库 > 问答 > 编程问答 >

jquery - Change style for all elements with a click event

问题描述:

I'm in the process of learning JQuery as I'm doing a major redesign of a site. I realize how nice it would be to do some styling in the javascript instead of remembering to add the right css class to every div (apparently, I like to forget such things).

Anyway, I want to add the style cursor: pointer; to all elements that have a click event registered. I think it needs to look something like this:

$("div").Find(/*Has Click Event*/)

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

网友答案:
$("div").each(function () {
    if($(this).data("events") !== 'undefined' && $(this).data("events").click) {
        $(this).css({"cursor": "pointer", "border": "1px solid red"});
    }
});​

Demo.

分享给朋友:
您可能感兴趣的文章:
随机阅读: