关于jQuery的一个例子_html/css_WEB-ITnose
$("#tableEmail td[background-color = dodgerblue]");
回复讨论(解决方案)
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)" });
有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即我们看到的下一个单元格了。

熱AI工具

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

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

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

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

HTML、CSS和JavaScript在Web開發中的作用分別是:1.HTML定義網頁結構,2.CSS控製網頁樣式,3.JavaScript添加動態行為。它們共同構建了現代網站的框架、美觀和交互性。

HTML的未來趨勢是語義化和Web組件,CSS的未來趨勢是CSS-in-JS和CSSHoudini,JavaScript的未來趨勢是WebAssembly和Serverless。 1.HTML的語義化提高可訪問性和SEO效果,Web組件提升開發效率但需注意瀏覽器兼容性。 2.CSS-in-JS增強樣式管理靈活性但可能增大文件體積,CSSHoudini允許直接操作CSS渲染。 3.WebAssembly優化瀏覽器應用性能但學習曲線陡,Serverless簡化開發但需優化冷啟動問題。

HTML的未來充滿了無限可能。 1)新功能和標準將包括更多的語義化標籤和WebComponents的普及。 2)網頁設計趨勢將繼續向響應式和無障礙設計發展。 3)性能優化將通過響應式圖片加載和延遲加載技術提升用戶體驗。

HTML、CSS和JavaScript在網頁開發中的角色分別是:HTML負責內容結構,CSS負責樣式,JavaScript負責動態行為。 1.HTML通過標籤定義網頁結構和內容,確保語義化。 2.CSS通過選擇器和屬性控製網頁樣式,使其美觀易讀。 3.JavaScript通過腳本控製網頁行為,實現動態和交互功能。

HTML是構建網頁結構的基石。 1.HTML定義內容結構和語義,使用、、等標籤。 2.提供語義化標記,如、、等,提升SEO效果。 3.通過標籤實現用戶交互,需注意表單驗證。 4.使用、等高級元素結合JavaScript實現動態效果。 5.常見錯誤包括標籤未閉合和屬性值未加引號,需使用驗證工具。 6.優化策略包括減少HTTP請求、壓縮HTML、使用語義化標籤等。

HTMLISNOTAPROGRAMMENGUAGE; ITISAMARKUMARKUPLAGUAGE.1)htmlStructures andFormatSwebContentusingtags.2)itworkswithcsssforstylingandjavascript for Interactivity,增強WebevebDevelopment。

HTML、CSS和JavaScript是構建現代網頁的核心技術:1.HTML定義網頁結構,2.CSS負責網頁外觀,3.JavaScript提供網頁動態和交互性,它們共同作用,打造出用戶體驗良好的網站。
