如何使用JQuery识别CSS'文本装饰'

Ste*_*eve 2 css jquery

一个相当明显的答案,因为你认为答案是这样的:

$(theelement).css('text-decoration');
Run Code Online (Sandbox Code Playgroud)

其中'theelement'是实际的(使用jqueryCSS).

我的问题是每当我尝试这个时它总会返回格式为的东西

none solid rgb(0, 0, 0)
Run Code Online (Sandbox Code Playgroud)

它看起来非常像边框CSS,而不是文本装饰CSS.

我把它放到一个小提琴中以简单的方式演示这个:点击这个JSFiddle

谢谢你的帮助!

Bar*_*mar 6

来自MDN:

:CSS文本修饰3级转化这个属性为三个新的简写text-decoration-color,text-decoration-linetext-decoration-styleCSS属性.

因此,当您阅读该属性时,您将获得所有三个组件属性.如果您不想要所有三个属性,请指定您想要的属性,例如

$(theelement).css('text-decoration-line')
Run Code Online (Sandbox Code Playgroud)

会回来的none.