說我有這樣的設置。jQuery .html()|它是否包含內聯風格?
<div id="error">
<p style="color:green">Success.</p>
<p style="color:red">Failure.</p>
<p style="color:green">Success.</p>
</div>
和在我的JavaScript我運行這樣的東西。
var response = $('#error').html();
if (response.indexOf('red') === -1) {
/*do stuff if #error has no style tags that have the color:red*/
}
這樣做還是我需要去做一個不同的方式?我想要一些見解,謝謝。
你試過了嗎 –
這太可怕了,但它可能會工作。 – plalx
'html()'將獲取樣式。但正如上面提到的,這似乎是一個非常糟糕的主意。 – Harry