我正在尝试使用 style.cssText 来显示使用 javascript 的隐藏段落。这是我的代码:
html:
<p class="toy-pictures-latest">Latest Toy Pictures</p>
<p class="toy-pictures-greatest">Greatest Toy Pictures</p>
CSS:
.toy-pictures-latest{
display: none;
}
.toy-pictures-greatest{
display: none;
}
js:
toy-pictures-latest.style.cssText = 'display: inline;';
我也试过
document.getElementById("toy-pictures-latest").style.cssText = 'display: inline;';
请参阅代码笔: Codepen
请让我知道我应该如何解决这个问题。