I have a submenu that slides out when the parent 'li' is hovered and that works ok. I am trying to have the background image of the parent 'li' change when this beahaviour happens.
$(function () {
$('nav li ul').hide().removeClass('fallback');
$('nav li').hover(function () {
//$('this').css('background-image','"url(' + images/arrow.png + ')"');
$('ul', this).stop().slideToggle(200);
});
});
The commented line is my failed attempt, but hopefully gives an idea of what I want to try.
Thanks!
You string concatenation is wrong
$(function () {
$('nav li ul').hide().removeClass('fallback');
$('nav li').hover(function () {
$('this').css('background-image','url(images/arrow.png)');
$('ul', this).stop().slideToggle(200);
});
});
$(this).css('backgroundImage', 'url(images/arrow.png)')
Arun关于字符串串联是正确的,但是您还需要从中删除单引号。
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.