简体   繁体   中英

Use hover or onmouseover/onmouseout?

I am building custom buttons( sliding doors ) for a new website. The buttons will not trigger a link but a javascript that then submits the form.

My solution is to use div (instead of link) with span within.

The question is if I should use onmouseover/onmouseout or is hover a preferred?

Pleas note : My website demands javascript else it wont work at all, so there is no problem to use javascript for the button, the question is which way that is the most correct?

我会用CSS做到这一点,因为它将需要更少的代码并且可以在禁用Javascript的情况下工作

If you are talking about jQuery events, it doesn't matter, it's the same.

If you're talking about HTML onmouseover/onmouseout vs. CSS:hover, go for CSS:hover. It's far easier to maintain, looks cleaner and decreases the size of your HTML which is a mess most times, anyways.

The solution for this is to simple use onmouseover/onmouseout on the div element. It will generate some code but it will be safe to use even in IE6.

This will ofcource demand javascript but that will have to do.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM