无法删除chrome中的style属性 [英] Unable to remove style attribute in chrome

查看:498
本文介绍了无法删除chrome中的style属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Chrome中从我的跨段移除样式时遇到问题。它可以有一堆不同的风格可能应用于它,所以我需要只是删除它whoesale。以下是此问题的示例,



jsfiddle *需要chrome



removeAttr('style')删除样式标签。当你打开调试栏,并突出显示跨度,它开始工作完美。



有人知道为什么风格没有被删除,如何删除它?

解决方案

我决定尝试一件事。将JQuery版本更改为1.5.2,它在Chrome中正常工作。所以,它似乎是一个错误在最新版本的JQuery。我建议你只使用1.5.2如果你可以逃脱它或建议Chrome用户更改浏览器。您也可以这样做:

 } else {
$('#s')。attr );
$('#s')。removeAttr('style');
}

而不是这样:

 } else {
$('#s')。removeAttr('style');
}

一个小错误修复/ b

http://jsfiddle.net/pjabT/7/ p>

I'm having troubles removing the styles from my span in Chrome. It can have a bunch of different styles possibly applied to it so I need to just remove it whoesale. Here is an example of the problem,

jsfiddle *requires chrome

The removeAttr('style') doesn't seem to be removing the style tag. When you open the debug bar though and highlight the span, it starts working perfectly.

Does anyone know why the style is not being removed and how to remove it?

解决方案

I decided to try one thing. Changing the JQuery version to 1.5.2 and it works fine in chrome. So, it appears it is a bug in the latest version of JQuery. I suggest you just use the 1.5.2 if you can get away with it or advise Chrome users to change browsers. You can also do this:

 } else {
   $('#s').attr('style');
   $('#s').removeAttr('style');    
 }

instead of this:

 } else {
   $('#s').removeAttr('style');    
  }

for a little bug-fix/hack.

http://jsfiddle.net/pjabT/7/

这篇关于无法删除chrome中的style属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆