-4

我需要设置一个类似于以下的 if 语句:

如果divID1元素style="display:block"divCLASS1添加 CSS style="margin-right:0px"

<script type="text/javascript">
<!--
           if ($('#w2btoTop').element.style('display') == 'block')
    $(".livehelp").css('margin-right','0px');
}
//-->
</script>

我不知道我在做什么,但很想看看我是否接近解决这个问题!

4

2 回答 2

3

以下应该有效:

if ($("#w2btoTop").css("display") === "block") {
    $(".livehelp").css("margin-right", "0px");
}

我建议您事先阅读官方 jQuery 文档。

于 2013-01-13T21:15:09.700 回答
1

这是检查元素可见性的一种方法:

$('#w2btoTop').is(":visible") // true if visible
$('#w2btoTop:visible').length // > 0 if visible
于 2013-01-13T21:21:43.123 回答