1. 程式人生 > >jQuery獲取button上的值

jQuery獲取button上的值

前端程式碼如下:

<div class="Tag-removable btn-group" role="group" aria-label="...">
    <button id="" type="button" class="btn btn-success btn-xs">{{$v.Tag_name}}</button>
    <button type="button" class="btn btn-success remove btn-xs">
        <span class="glyphicon glyphicon-remove"
aria-hidden="true">
</span> </button> </div>

獲取第一個button元素上的值:

$("div.Tag-removable").find("button:first-child").text();

$("div.Tag-removable").find("button").get(0).text();

$("div.Tag-removable").find("button").first().text();