Calling JavaScript from function from CSS

后端 未结 5 927
夕颜
夕颜 2020-12-14 08:18

Is there any way that I can call my JavaScript function from css?

For ex here is style:

.first-nav li a:hover,
.first-nav li.hover a {
    margin:-3         


        
5条回答
  •  无人及你
    2020-12-14 09:02

    No.

    (Well, Microsoft Expressions and Mozilla Bindings might allow it, but both are proprietary and should be avoided)

    Assign your event handlers from JavaScript. Libraries such as YUI and jQuery allow you to pick elements to apply them to using CSS selectors. Event delegation allows you to handle events on elements without having to assign to each one explicitly (which is handy if you are adding them to the document after it loads).

提交回复
热议问题