jQuery獲取button上的值
阿新 • • 發佈:2019-02-08
前端程式碼如下:
<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();