Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change style for all elements with a click event

Tags:

jquery

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");
like image 360
chezy525 Avatar asked Nov 04 '22 04:11

chezy525


1 Answers

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

Demo.

like image 188
karim79 Avatar answered Nov 07 '22 20:11

karim79