感谢您的支持,我会继续努力的!
打开微信扫一扫,即可进行扫码打赏哦
点我查看本站打赏源码!
Powered by RUNCODEX.COM,学的不仅是技术,更是梦想!!!
<script src="https://cdn.staticfile.org/jquery/2.2.4/jquery.min.js"></script>
<body>
<h2>这是一个标题</h2>
<p style="background-color:#ff0000">这是一个段落。</p>
<p style="background-color:#00ff00">这是一个段落。</p>
<p style="background-color:#0000ff">这是一个段落。</p>
<button>返回第一个 p 元素的 background-color </button>
</body>
xxxxxxxxxx
$("button").click(function(){
alert("p1背景颜色 = " + $("p:nth-child(2)").css("background-color"));
alert("p2背景颜色 = " + $("p:nth-child(3)").css("background-color"));
alert("p3背景颜色 = " + $("p:nth-child(4)").css("background-color"));
});
输入 CSS 代码……