如何使用 jQuery 从 Div 中删除特定的 CSS 属性?
使用 jQuery 从 Div 中删除 CSS
在您的应用程序中,您有一个将 CSS 属性应用于 div 的单击事件处理程序。但是,在执行其他功能后,您希望删除应用的 CSS。以下是使用 jQuery 实现此目的的方法:
<p>In my App I have the following:</p> <pre class="brush:php;toolbar:false">$("#displayPanel div").live("click", function(){ $(this).css({'background-color' : 'pink', 'font-weight' : 'bolder'}); // Perform other functionalities here // Remove the applied CSS $(this).css({'background-color' : '', 'font-weight' : ''}); });
When I click on a Div, the color of that Div is changed. Within that Click function I have some functionalities to do. After all that I want to remove the applied Css from the Div. How could I do it in JQuery?
”问题答案:“You can remove specific CSS that is on the element like this:
$(this).css({'background-color' : '', 'font-weight' : ''});
Although I agree with karim that you should probably be using CSS classes.
”css() 方法接受键值对对象作为参数。通过传递空字符串 ('') 作为值,您可以有效地删除指定的 CSS 属性。在本例中,我们删除了之前应用于 div 的背景颜色和字体粗细属性。
以上是如何使用 jQuery 从 Div 中删除特定的 CSS 属性?的详细内容。更多信息请关注PHP中文网其他相关文章!

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

您是否曾经在项目上需要一个倒计时计时器?对于这样的东西,可以自然访问插件,但实际上更多

格子呢是一块图案布,通常与苏格兰有关,尤其是他们时尚的苏格兰语。在Tartanify.com上,我们收集了5,000多个格子呢

我关注的一件事是Lea Verou&#039; s conic-Gradient()Polyfill的功能列表是最后一项:
