这是一个创建于 3008 天前的主题,其中的信息可能已经有所发展或是发生改变。
页面里有好几个 div
<div class="post"><span class="postid" style="color:fff"></span></div>
<div class="post"><span class="postid" style="color:888"></span></div>
<div class="post"><span class="postid" style="color:ccc"></span></div>
想让 post 里的 color 跟 postid 里的一样,咋写?
if ($('div.post .postid').hasClass("color")) {
$('div.post').addClass("color");
}
var cc = $('div.post .postid').css("color");
$this('div.post').css(cc);
??????
具体怎么写?我不太会,帮我写一个呗?谢啦~万分感谢。
14 条回复 • 2016-07-12 17:22:04 +08:00
|
|
2
cxlxkin 2016-07-12 16:53:07 +08:00
学编程不能让别人帮你写,别人提供思路,自己去摸索写,这样才能学到东西的
|
|
|
4
cxbig 2016-07-12 17:03:48 +08:00 1
这题目也是奇葩,这年头还在折腾 HTML DOM Style 。
|
|
|
5
tester4 2016-07-12 17:06:06 +08:00
|
|
|
6
cxlxkin 2016-07-12 17:07:43 +08:00
|
|
|
8
cxbig 2016-07-12 17:13:06 +08:00
@ tester4 不要浪费时间在这种无意义的实现上
|
|
|
10
tester4 2016-07-12 17:13:40 +08:00 1
|
|
|
11
issuz 2016-07-12 17:17:44 +08:00
$('.post .postid').each(function(){ $(this).closest('.post').css('color',$(this).css('color')); })
|
|
|
12
tester4 2016-07-12 17:18:49 +08:00
|
|
|
13
tester4 2016-07-12 17:20:58 +08:00
|
|
|
14
issuz 2016-07-12 17:22:04 +08:00 via iPhone
|