我在 js 和 jQuery 中为简单的 html 设置样式时遇到了各种麻烦,这里似乎使用了一个 jsfiddle 来说明。我是新手,看不到控制台输出或期望的结果,所以我问这个问题以了解更多关于如何提供帮助的信息;我确实搜索过 .css 不工作和变体
javascript
.css() 是 jQuery。 .style 是 js。
document.getElementsByTagName('pre').text.css("color: blue;"); jquery: const preSentences = $("pre").text().split(".") console.log({preSentences})
//no err no workee in chrome
// preSentences.forEach(function(str) { $(this).css("color: blue; border: 1px solid black")}); // $.each(preSentences, function(str) { $(this).blue }) // preSentences[1].style("color: blue; border: 1px solid black");
我想小提琴就在这里-我尝试了嵌入链接,但它没有显示出来: https ://jsfiddle.net/Lz8nh50o/