jQuery通过类单击更改CSS

jQuery通过类单击更改CSS,jquery,javascript-events,Jquery,Javascript Events,这让我发疯,我尝试过多种方法,但都没有效果。有任何jQuery神能帮助我吗 jQuery: $(".FCChatControl").click(function(event) { var id = $(this).attr("rel"); var wnd = $(id); if (wnd.style.marginBottom == "-1px") { $(wnd).css({"margin-bottom": "-236px"}); } else {

这让我发疯,我尝试过多种方法,但都没有效果。有任何jQuery神能帮助我吗

jQuery:

$(".FCChatControl").click(function(event) {
    var id = $(this).attr("rel");
    var wnd = $(id);
    if (wnd.style.marginBottom == "-1px") {
        $(wnd).css({"margin-bottom": "-236px"});
    } else {
        $(wnd).css({"margin-bottom": "-1px"});
    }
});
执行日期:

<a href="javascript:void(0)" rel="#item.OwnerID#" id="FCChatControlID" class="FCChatControl">
    <div id="cw-header">
        <h1>#item.Nickname#</h1>
    </div>
</a>

现在还不完全清楚您在追求什么,但现在您需要检查CSS属性并对其采取行动


顺便说一下,您的
else
子句似乎毫无意义,所以我删除了它。

控制台显示了什么错误?未捕获的TypeError:无法读取未定义的
.style的属性“marginBottom”。marginBottom
是纯JavaScript,您正在向它传递一个jQuery对象。我如何检查元素CSS是否是jQuery中的某个值?我只见过如何设置。只要看一下说明书就行了$(wnd).css(“页边距底部”);//末尾带有px字符
$('.FCChatControl').click(function() {
    if ($(this).css('margin-bottom') == "-1px") {
        $(this).css('margin-left', '50px'); // demo
    }
});