jquery - How to remove class hover -
listen guys im here again, have trouble , donk know how search problmen in web (i searched "remove hover" , didnt find wanted).
i have style one:
.mystyle li:hover { background: #9999ff; }
and have in html
<ul class="mystyle"> <li id="li1">1</li> <li id="li2">2</li> <li id="li3">3</li> </ul>
and have script too
$('ul li').on('click', function() { $(this).prependto(list.closest('ul')); }
so now, works perfectly, li moved conserves color of class (#9999ff) after click, , doesnt quit until pass mouse on there. have tried remove class removeclass doesnt work, please me.
any ideas problem?
thank u time!
no, can't, can attach styles not tags classes , on hover event can delete/add class.
in jquery hover combination of mouseenter , mouseleave events, can bind handler hover start:
css:
.hoverable { /* styles */ } .hoverable:hover { /* styles want not attach */ }
html:
<ul> <li class="hoverable">hover not makes effect</li> <li>hover makes effect</li> </ul>
javascript:
var classname = 'hoverable'; $('ul li').on('mouseenter', function(e) { $(this).removeclass(classname); }).on('mouseleave', function(e) { $(this).addclass(classname); });
(jsfiddle here)
so it's possibly can prevent unwanted effect.
and, of course, instead of can redefine styles , set unwanted styles 'inherit' etc., better solution.
also, there similar question on stackoverfow: can disable css :hover effect via javascript?
Comments
Post a Comment