作者:吸烟有害但是健康1988 | 来源:互联网 | 2023-05-18 06:31
不多说,直接上代码
- <div class="body pB5 redB border_01">
- <ul id="ul_cartList" class="cartlistul">
- <li>
- <span class="pro_name"> 10086.我爱你 span>
- <span class="pro_delete"><a href="Javascript:deleteCartAjax('10086.我爱你')">删除a>span>
- li>
- <li>
- <span class="pro_name"> 你发了.广东 span>
- <span class="pro_delete"><a href="Javascript:deleteCartAjax('你发了.广东')">删除a>span>
- li>
- <li>
- <span class="pro_name"> 你发了.集团span>
- <span class="pro_delete"><a href="Javascript:deleteCartAjax('你发了.广东')">删除a>span>
- li>
- ul>
-
- div> <button onclick="clickButton();">clickbutton>
我想拿到li里面class为pro_name的每个span里面的值,
- function clickButton(){
-
- var liLength = $("#ul_cartList li").length;
-
- for(var i = 0; i < liLength; i++){
- var spanElement = $("#ul_cartList li span.pro_name")[i];
- alert(spanElement.innerHTML);
-
-
- }
- }