拿出李jquery的价值

时间:2015-07-06 09:50:27

标签: javascript jquery

我已经给出了

<ul class="test1" style="height: 175px;">
    <li class=" ">
        <label class="ui-corner-all" title="" for="ui-multiselect-apps_data_usage_operator_country-option-0">
            <input type="checkbox" aria-selected="true" title="" value="All" name="multiselect_apps_data_usage_operator_country" id="ui-multiselect-apps_data_usage_operator_country-option-0"><span>All</span>
        </label>
    </li>
    <li class=" ">
        <label class="ui-corner-all" title="" for="ui-multiselect-apps_data_usage_operator_country-option-1">
            <input type="checkbox" title="" value="1" name="multiselect_apps_data_usage_operator_country" id="ui-multiselect-apps_data_usage_operator_country-option-1" aria-selected="true"><span>XYZ</span>
        </label>
    </li>
</ul>

现在我想从li中取出span的值,其中输入aria-selected =&#34; true&#34;通过jquery。请帮帮我。

3 个答案:

答案 0 :(得分:0)

您可以使用:

$('li input[aria-selected="true"] + span').text();

<强>段

&#13;
&#13;
$(function () {
  alert($('li input[aria-selected="true"] + span').text());
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<ul class="test1" style="height: 175px;">
  <li class=" ">
    <label class="ui-corner-all" title="" for="ui-multiselect-apps_data_usage_operator_country-option-0">
      <input type="checkbox" aria-selected="true" title="" value="All" name="multiselect_apps_data_usage_operator_country" id="ui-multiselect-apps_data_usage_operator_country-option-0"><span>All</span>
    </label>
  </li>
  <li class=" ">
    <label class="ui-corner-all" title="" for="ui-multiselect-apps_data_usage_operator_country-option-1">
      <input type="checkbox" title="" value="1" name="multiselect_apps_data_usage_operator_country" id="ui-multiselect-apps_data_usage_operator_country-option-1" aria-selected="true"><span>XYZ</span>
    </label>
  </li>
</ul>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

请尝试此

   <android.support.v7.widget.RecyclerView
    android:id="@+id/drawerList"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="15dp"
    />

Demo

答案 2 :(得分:0)

简单的一个班轮可能会这样做。

alert($(":checkbox[aria-selected='true'] + span").text());

DEMO