<li class="last">
<div class="arrow"></div>
<div class="checkbox checked"></div> <input type="checkbox" id="3ac51f7f-f056-4038-9b98-e3619c338657' " name="workscrope" xpath="009002" value="3ac51f7f-f056-4038-9b98-e3619c338657" style="display: none;">
 
 <span>紫外/可见分光光度计</span>
 
  </li>
怎么找<div class="checkbox checked"></div>后面的span的值?

解决方案 »

  1.   

    $("div .checked").next().find("span").html()
      

  2.   

    找到SPAN,然后得到span的INNERHTML就是SPAN的值
      

  3.   

    <li class="last">
    <div class="arrow"></div>
    <div class="checkbox checked"></div> <input type="checkbox" id="3ac51f7f-f056-4038-9b98-e3619c338657' " name="workscrope" xpath="009002" value="3ac51f7f-f056-4038-9b98-e3619c338657" style="display: none;">
     
     <span>紫外/可见分光光度计</span>
     
      </li>
    1、alert($("div.checkbox.checked").next("span").text());
       alert($("div.checkbox.checked").next("span").html());2、alert($("div.checkbox.checked").next().next().text());
       alert($("div.checkbox.checked").next().next().html());3、alert($("div.checkbox.checked").nextAll("span").ext());
       alert($("div.checkbox.checked").nextAll("span").html());4、alert($("div.checkbox.checked").nextUntil("span").ext());
       alert($("div.checkbox.checked").nextUntil("span").html());还有可以$("li.last span").html();
      

  4.   


    不知道lz有没有测试,至少有几个是可以的
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>c.html</title>
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript">
         $(function () {
    alert($("div.checkbox.checked").next("input").next("span").text());
    alert($("div.checkbox.checked").next("input").next("span").html());

    alert($("div.checkbox.checked").next().next().text());
    alert($("div.checkbox.checked").next().next().html());

    alert($("div.checkbox.checked").nextAll("span").text());
    alert($("li.last span").html());
         });
        </script> </head> <body>
    <li class="last">
    <div class="arrow"></div>
    <div class="checkbox checked"></div>
    <input type="checkbox" id="3ac51f7f-f056-4038-9b98-e3619c338657' "
    name="workscrope" xpath="009002"
    value="3ac51f7f-f056-4038-9b98-e3619c338657" style="display: none;">
    <span>紫外/可见分光光度计</span>
    </li>
    </body>
    </html>
      

  5.   


    alert($("div[class='checkbox checked'] ~ span").text());
      

  6.   


    使用html()方法当然不可以啊,取的是文本要使用text()方法。