更改div的颜色并使用Jquery删除span的文本

时间:2012-01-05 08:11:03

标签: jquery

<td class="tdLeftZoneCss" id="tdLeftZone">
<div>
<div style="border-bottom-color: black;">
<span>John</span>

1)我想改变2nd Div的颜色(黑色到#F2F2F2)

2)我想删除用span

写的文本('John')

如何使用Jquery做到这一点?

4 个答案:

答案 0 :(得分:2)

$('#tdLeftZone > div > div')               // find inner div
   .css('border-bottom-color', '#f2f2f2')  // change its style
   .children('span:first')                 // then find the first span
   .empty();                               // and erase its contents

答案 1 :(得分:2)

试试这段代码,

$('.tdLeftZoneCss span').text('').parent().css('border-bottom-color','#F2F2F2');

答案 2 :(得分:1)

$("#tdLeftZone div div ").css('color','#f2f2f2').children('span:first').empty();

答案 3 :(得分:0)

也许你可以试试这个.. 将你的JQuery作为父母和孩子玩,删除&amp;改变..

<div id="Destination"> 
    <div class="child_content"> item destination 1 </div>
    <div class="child_content"> item destination 2 </div>
</div>

    <div id="Source"> 
    <div class="child_content"> item source 1 </div>
    <div class="child_content"> item source 2 </div>
</div>

      <script type="text/javascript"> 
        $(document).ready(function(){
            $("#Source .child_content").click(function(){
                $(this).parent().remove();
                $(this).appendTo("#Destination");
                $(this).parent().css({"background":"black","color":"white"});
            });
        });
    </script>