Jquery的子元素过滤选择器 中 比如:first-child 选择父元素的第一个子元素 ,
那文本元素算不算第一个元素??

解决方案 »

  1.   

    比如 $("div input:first-child")是选取每个DIV下边的第一个input子元素
    如果是 $("div :first-child")是选取每个DIV下边所有元素中的第一个 你可以在所有标记前写上一段文字测下啊
      

  2.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
            <title></title>
    <script type="text/javascript" src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'></script>
    <script type="text/javascript">
    $(function(){
    alert($("#test").text());
    }); </script>
        </head>
        <body>
    <div id="test">asdfjlasdf<span>thatsss</span>asldfjl</div>
        </body>
    </html>
      

  3.   

    汗 我测试了哈 算的
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
                        "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
      <script src="http://code.jquery.com/jquery-latest.js"></script>
      
      <script>
      $(document).ready(function(){
        
        alert($("#cc:first-child").html());  });
      </script>
      <style>
      span { color:#008; }
      span.sogreen { color:green; font-weight: bolder; }
      </style>
    </head>
    <body>
      <div>
        <span>John,</span>
        <span>Karl,</span>
        <span>Brandon</span>
      </div>
      <div>
        <span id="cc">Glen,</span>
        <span>Tane,</span>
        <span>Ralph</span>
      </div>
    </body>
    </html>
      

  4.   

    alert($("#cc:first-child").html());
    你想知道你取出来的DOM是什么吗?
      

  5.   

     alert($("#cc:first-child").attr('id'));
    试试
      

  6.   

    正在学习jQuery,还需要继续努力啊