chezy525
chezy525

Reputation: 4174

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");

Upvotes: 5

Views: 879

Answers (1)

karim79
karim79

Reputation: 342635

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

Demo.

Upvotes: 2

Related Questions