javascript - JQuery 在 chrome 中工作但在 IE 11 中不工作

标签 javascript jquery html jsp

这个 JQuery 在 chrome 中工作,但在 IE 中不工作

$('body').append("<style>.homeBannerQuote {\r\n width:100%;\r\n height: 300px;\r\n}\r\n\r\n\r\n.bannerBG {\r\n background: url(https:\/\/someImageURL.png) 0 0 no-repeat;\r\n background-size:650px auto;\r\n background-position: 100% 25%;\r\n \r\n}\r\n\r\n\r\n\/* Headlines *\/\r\n\r\n.bannerBG h1, .bannerBG h2, #content table:first-of-type td:nth-child(2) h2 {\r\n\tmargin: 0;\r\n font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;\r\n text-shadow: 2px 2px 2px #000;\r\n font-weight:bold;\r\n margin-left:5%;\r\n}\r\n\r\n.bannerBG h1 {\r\n\tfont-size: 3em;\r\n\tcolor: #FA9E00;\r\n margin-top:200px;\r\n}\r\n\r\n.bannerBG h2, #content table:first-of-type td:nth-child(2) h2 {\r\n\tfont-size: 2.4em;\r\n\tcolor: #fff;\r\n margin-bottom: 3%;\r\n}\r\n\r\n #content table:first-of-type td:nth-child(2) h2 {\r\n text-align:center;\r\n margin: 40px auto 20px auto;\r\n}\r\n\r\n\/* Quote Box *\/\r\n\r\n#content table:first-of-type td:nth-child(2) {\r\nbackground:#066DB5;\r\n}\r\n\r\n\r\n\r\n#quotedropdowns {\r\n left: 688px !important;\r\n top: 100px !important;\r\n width:250px !important;\r\n}\r\n.tundra .dijitTextBox {font-size:1.5em;}\r\n#widget_states {width:150px;}\r\n\r\n\/* Button *\/\r\n\r\n.whitetext.smoothbox {\r\n\tborder-radius: 3px;\r\n background:#ff8a00;\r\n display:block;\r\n width:200px;\r\n height:20px;\r\n padding:5px;\r\n text-align:center;\r\n margin:auto;\r\n}\r\n\r\n#quotebuttontext {\r\n left:688px !important;\r\n top:190px !important;\r\n }\r\n\r\ntable#emailAddressForm {\r\n display: none;\r\n}<\/style>");

我认为 nth-child 可能存在一些问题, 我尝试使用 td:first-child + td ,但它在 IE 中仍然不起作用。预先感谢您的帮助。

最佳答案

没错,IE 不支持 nth-child。您可以使用此站点来跟踪您可以使用或不能使用的内容:https://caniuse.com/#search=nth-child

但是 first-child 应该可以工作,因为它被 IE 支持:https://caniuse.com/#search=first-child

关于javascript - JQuery 在 chrome 中工作但在 IE 11 中不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51667815/

相关文章:

javascript - 如何在 HTML 页面中加载多个 javascript 文件

javascript - chrome 扩展 - 将消息从内容脚本发送到后台页面并返回到内容脚本?

javascript - Jasmine 测试检查 html 是否包含文本并返回 bool 值

javascript - SlickNav 菜单,每个 li 都有特定的颜色背景?

javascript - 从外部 API 更新 Redux 存储

javascript - localscroll.js - 似乎无法弄清楚如何设置链接

javascript - 将列表中 `li` 的颜色更改为平均图像颜色

javascript - Sencha-touch 2 - 选项卡面板内的表单

javascript - 使用 jquery 动态连接两个形状之间的线连接器

html - 如何在一个部分或 div 中自由移动元素?