JQuery toggle is hiding the div element

≡放荡痞女 提交于 2019-12-02 02:37:37

toggle() (Event) event is deprecated in jQuery 1.8 and removed in jQuery 1.9.

Current .toggle() function changes the state of the element.


$(document).ready(function () {
    $(".noticia").click(function(){
        $(this).css('height', $(this).css('height') == "420px" ? "600px" : "420px");
    });
});

jQuery toggle shows or hides an element, it doesn't toggle a function.

To toggle height like you would like to, it would probably be best to introduce a new CSS class into your CSS file and use jQuery toggleClass to either add or remove the class. So:

JS changes to this:

$(document).ready(function () {
    $(".noticia").toggleClass('large');
});

CSS addition of class:

.noticia.large {
    height: 600px;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!