<script>
$("div:contains('John')").css("text-decoration", "underline");
</script>
幾乎我想運行一個函數,而不是改變div的CSS屬性。 例如,如果有一個名稱包含約翰執行$(selector).click();
檢查文本是否存在,然後運行功能
任何想法?
<script>
$("div:contains('John')").css("text-decoration", "underline");
</script>
幾乎我想運行一個函數,而不是改變div的CSS屬性。 例如,如果有一個名稱包含約翰執行$(selector).click();
檢查文本是否存在,然後運行功能
任何想法?
檢查DIV長度不能爲空
if ($('div:contains("John")').length>0) {
// your script here
}
if語句不會做? – karthikr 2014-08-29 14:44:16
[jQuery:檢查文本是否存在於另一個元素中]的可能重複(http://stackoverflow.com/questions/9300123/jquery-check-if-text-exists-in-another-element) – ctwheels 2014-08-29 15:09:27