我有以下代码:
<script type="text/javascript">
function shownavall()
{
$('#shownavall').slideToggle('slow', function() {
$('.otherlink').toggle(function(){
$(this).css('background-position', '0px 0px');
}, function(){
$(this).css('background-position', '25px 0px');
});
});
}
</script>
当我尝试调用该函数时,该函数在slidetoggle
零件上起作用。但是不改了css
我.otherlink
想知道为什么?以及如何解决?
我试图通过使用条件语句来做到这一点,这是我的代码:(此代码根本不起作用!)
function shownavall()
{
$('#shownavall').slideToggle('slow', function() {
if ($('.otherlink').css('background-position') == '25px 0px')
{
$(.otherlink).css('background-position', '0px 0px');
}
else
{
$(.otherlink).css('background-position', '25px 0px');
}
});
}
我 100% 确定错误出在我的 Jquery 代码中。所以请不要询问html或css。