Skip to content Skip to sidebar Skip to footer

Call A Javascript Function From Css

I would like to know if its possible in any way to: .button{ width: somePX; height: somePX; } .button:hover { onmouseup = 'func('.button')'; } or something like that. I think

Solution 1:

you can't use CSS to do it, but you can use something like jquery to use selectors to attach functions to elements.

Solution 2:

With jQuery, you could do something like:

$('.button').on('mouseup', function(){...});

CSS is a styling language, so you cannot modify the behaviour of HTML elements with it, only their style. If you wish to modify the behaviour, you can use JavaScript.

You could also use an Angular.js Class directive to change the behaviour of all elements with the .button class. But again, this is a JS library and not CSS.

Solution 3:

Hey buddy CSS doesn't have such kinda functionality. However you can use CSS selectors with jQuery.

Post a Comment for "Call A Javascript Function From Css"