$("#tableEmail td[background-color = dodgerblue]");但是就是没有结果。其它的几个属性也用了,如:bgColor,background和backgroundColor,但还是不行,不知道为什么,用filter或not也不行。谁知道怎么写?程序逻辑应该没问题的。另外说一下上面几个背景色的应用场合和区别,我觉得还是不要混用为好。
回复讨论(解决方案)
background-color为rgb格式,不是dodgerblue
建议你使用class设置背景颜色
你可以这样
var x = $('#tableEmail td').filter(function() {
return $(this).css('background-color') == 'rgb(30, 144, 255)';
})
x.html("xxxxxxx")
x就是那个td
IE中这样写
$('#tableEmail td').filter(function() {
return $(this).css('background-color') == 'dodgerblue';
})
例子
<html><head><script src="jquery-1.9.1.min.js"></script></head><body> <table id="tableEmail"> <tr> <td style="background: dodgerblue">sdsd</td> <td style="background: red">sdsd</td> </tr> </table> <input type=button value=test onclick="xx()"> <script> function xx() { alert($('#tableEmail td').css("background-color")) $('#tableEmail td').filter(function() { return $(this).css('background-color') == 'dodgerblue'; }).html("xxxxxxx") } </script></body></html>
你可以这样
var x = $('#tableEmail td').filter(function() {
return $(this).css('background-color') == 'rgb(30, 144, 255)';
})
x.html("xxxxxxx")
x就是那个td
IE中这样写
$('#tableEmail td').filter(function() {
return $(this).css('background-color') == 'dodgerblue';
})
例子
<html><head><script src="jquery-1.9.1.min.js"></script></head><body> <table id="tableEmail"> <tr> <td style="background: dodgerblue">sdsd</td> <td style="background: red">sdsd</td> </tr> </table> <input type=button value=test onclick="xx()"> <script> function xx() { alert($('#tableEmail td').css("background-color")) $('#tableEmail td').filter(function() { return $(this).css('background-color') == 'dodgerblue'; }).html("xxxxxxx") } </script></body></html>
确实是的,我测试了一下,IE将background-color解析成颜色名,而Chrome, Firefox和Safari都解析成rgb值。我想问能有通过颜色名得到rgb的方法吗。还有就是我用
var select = td.filter(function () { return $(this).css("background-color") == "rgb(30, 144, 255)" });select.next()得到下一个单元格,可就是为空,不知道怎么回事。
有2个方法
1,使用Color.js,下载使用方法参见name2rgb http://matthewbj.github.io/Colors/
2,使用json预定义
http://stackoverflow.com/questions/1573053/javascript-function-to-convert-color-names-to-hex-codes
有2个方法
1,使用Color.js,下载使用方法参见name2rgb http://matthewbj.github.io/Colors/
2,使用json预定义
http://stackoverflow.com/questions/1573053/javascript-function-to-convert-color-names-to-hex-codes
谢谢你,还有就是为什么select.next()得不到下一个单元格?
有2个方法
1,使用Color.js,下载使用方法参见name2rgb http://matthewbj.github.io/Colors/
2,使用json预定义
http://stackoverflow.com/questions/1573053/javascript-function-to-convert-color-names-to-hex-codes
谢谢你,还有就是为什么select.next()得不到下一个单元格?
我知道为什么了,因为各个td位于不同的tr中,并不是兄弟关系,而我的td都只有1个,所以select.next()为空。正确的做法是select.parent().next().children().first(),先得到父元素tr,然后得到下一个tr,再得到tr所有子元素td,最后得到第一个子元素td即我们看到的下一个单元格了。

WebDevelovermentReliesonHtml,CSS和JavaScript:1)HTMLStructuresContent,2)CSSStyleSIT和3)JavaScriptAddSstractivity,形成thebasisofmodernWebemodernWebExexperiences。

HTML的作用是通過標籤和屬性定義網頁的結構和內容。 1.HTML通過到、等標籤組織內容,使其易於閱讀和理解。 2.使用語義化標籤如、等增強可訪問性和SEO。 3.優化HTML代碼可以提高網頁加載速度和用戶體驗。

htmlisaspecifictypefodyfocusedonstructuringwebcontent,而“代碼” badlyLyCludEslanguagesLikeLikejavascriptandPytyPythonForFunctionality.1)htmldefineswebpagertuctureduseTags.2)“代碼”代碼“ code” code code code codeSpassSesseseseseseseseAwiderRangeLangeLangeforLageforLogageforLogicIctInterract

HTML、CSS和JavaScript是Web開發的三大支柱。 1.HTML定義網頁結構,使用標籤如、等。 2.CSS控製網頁樣式,使用選擇器和屬性如color、font-size等。 3.JavaScript實現動態效果和交互,通過事件監聽和DOM操作。

HTML定義網頁結構,CSS負責樣式和佈局,JavaScript賦予動態交互。三者在網頁開發中各司其職,共同構建豐富多彩的網站。

HTML適合初學者學習,因為它簡單易學且能快速看到成果。 1)HTML的學習曲線平緩,易於上手。 2)只需掌握基本標籤即可開始創建網頁。 3)靈活性高,可與CSS和JavaScript結合使用。 4)豐富的學習資源和現代工具支持學習過程。

AnexampleOfAstartingTaginHtmlis,beginSaparagraph.startingTagSareEssentialInhtmlastheyInitiateEllements,defiteTheeTheErtypes,andarecrucialforsstructuringwebpages wepages webpages andConstructingthedom。

如何設計菜單中的虛線分割效果?在設計菜單時,菜名和價格的左右對齊通常不難實現,但中間的虛線或點如何...


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

Atom編輯器mac版下載
最受歡迎的的開源編輯器

SecLists
SecLists是最終安全測試人員的伙伴。它是一個包含各種類型清單的集合,這些清單在安全評估過程中經常使用,而且都在一個地方。 SecLists透過方便地提供安全測試人員可能需要的所有列表,幫助提高安全測試的效率和生產力。清單類型包括使用者名稱、密碼、URL、模糊測試有效載荷、敏感資料模式、Web shell等等。測試人員只需將此儲存庫拉到新的測試機上,他就可以存取所需的每種類型的清單。

DVWA
Damn Vulnerable Web App (DVWA) 是一個PHP/MySQL的Web應用程序,非常容易受到攻擊。它的主要目標是成為安全專業人員在合法環境中測試自己的技能和工具的輔助工具,幫助Web開發人員更好地理解保護網路應用程式的過程,並幫助教師/學生在課堂環境中教授/學習Web應用程式安全性。 DVWA的目標是透過簡單直接的介面練習一些最常見的Web漏洞,難度各不相同。請注意,該軟體中

SublimeText3 Linux新版
SublimeText3 Linux最新版

EditPlus 中文破解版
體積小,語法高亮,不支援程式碼提示功能