0

我在phonegap工作我想计算锚标签的主题这是我的代码
我只想计算li中锚标签中的主题b

<ul id='uSignUp' onclick="getlistitem()"  data-role='listview' data-inset='true' data-split-theme="d" data-theme="a">
            <li><a href='#'   rel="external">Accessing Your Needs</a>
            <a href="#" data-theme="b" id="A_an"  data-icon="check"> Accessing your needs status</a>
            </li>
            <li><a href='#' onclick="ToShowDF();"   rel="external">Develop Your Fitness</a>
            <a href="#"  data-theme="b" id="A_df"   data-icon="check"> Develop your fitness status</a>
            </li>
            <li><a href='#' onclick="ToShowPQ();"  rel="external">PAR-Q</a>
            <a href="#"  data-theme="d"  id="A_pq" data-icon="check"> PAR-Q Form</a>
            </li>
            <li><a href='#' onclick="ToShowLS();"  rel="external">Lifestyle Related Questions</a>
            <a href="#"  data-theme="d"  id="A_ls"  data-icon="check"> LifeStyle  status</a>
            </li>
           <li><a href='#' onclick="ToShowTNC();"  rel="external">Terms And Conditions</a>
            <a href="#"  data-theme="d"  id='A_Tnc' data-icon="check"> Terms and Conditions status</a>
           </li>
            <li><a href='#' onclick="ToShowIND();"  rel="external">Indemnity Declaration</a>
            <a href="#"  data-theme="d"  id='A_ind' data-icon="check"> Indemnity declaration status</a>
            </li>                
    </ul>   

当我在 firebug 中调试代码时,它会显示一个 div 和一个锚标记,并且在锚标记中有两个跨度,在第二个跨度上我需要那个。

谁能帮忙?

4

2 回答 2

0
var count = 0;
$('#uSignUp > li > a').each(function() {
    var theme = $(this).data("theme");
    if (theme != undefined && theme == 'b') {
        //console.log($(this).data("theme"));
        count++;
    }
})

alert(count);​

小提琴

于 2012-12-30T11:58:20.967 回答
0

尝试:

var countB = $('#uSignUp [data-theme="b"]').length;

alert( countB );

小提琴演示

于 2012-12-30T11:14:47.643 回答