查找我的元素已应用“内联"样式 [英] Find my element has `inline` style applied
本文介绍了查找我的元素已应用“内联"样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个元素,从该元素如何知道它是否应用了inline
样式?
I have an element, from the element how do i know whether it has the inline
style applied or not?
示例:
html:
<span style="border:1px solid red;">Testing</span>
//<span>Testing</span> //without style as well getting some in build info
js:
var sty = $('span').prop('style');
console.log(sty); //it always consoles something!
推荐答案
var sty = $('span').is('[style]');
if(sty)
{
//style is present
}
else
{
//style is not present
}
Demo
这篇关于查找我的元素已应用“内联"样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文