I have this jquery codes:
$(document).ready(function() {
$("#masthead ul li").mouseover(function(){
$("#masthead ul li").removeClass("cr");
$(this).toggleClass("cr");
});
});
$(document).ready(function() {
$("#intUl li").mouseover(function(){
$("#intUl li").removeClass("cr");
$(this).toggleClass("cr");
});
});
Can we write shorthand for two similar jquery code? Thanks in advance
$('#masthead ul li, #intUL li').mouseover(function() {
$(this).siblings().removeClass("cr");
$(this).toggleClass("cr");
});
Does the same as the original code; not sure why you're removing a class only to readd it, however. If you're trying to get it to flash or something, I'm fairly sure it won't work as you're expecting.
Misunderstood original intent; a commenter clarified for me, and I fixed it :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With