[英]how do you add inline styles in jquery?
Hi so this what I have in jquery however it doesn't seem to work, am I missing something?嗨,这是我在 jquery 中所拥有的,但它似乎不起作用,我错过了什么吗?
modalClose.on("click", () => {
modalContainer.removeClass("modal-open");
modalContainer.attr("style", "display:none");
});
You use the css function, passing it an object with the properties, you use camel case rather than hyphens.您使用 css 函数,将一个带有属性的对象传递给它,您使用驼峰式大小写而不是连字符。
modalClose.on("click", () => { modalContainer.removeClass("modal-open"); modalContainer.css({display: 'none'}); });
//Use camel case for properties with hyphens. style="display: none; background-color: #FFFFFF" jQuery('.youritem').css({display: 'none', backgroundColor: '#FFFFFF'})
To remove a property from your html send an empty string to the property, the following removes both the display and background-color properties.要从 html 中删除属性,请向该属性发送一个空字符串,以下内容将同时删除 display 和 background-color 属性。
jQuery('.youritem').css({display: '', backgroundColor: ''})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.