我在js中有下面的字符串,我只想从完整的字符串下面得到 Approval 批准,
<span class="label label-sm label-warning">Approval</span>
谢谢
答案 0 :(得分:0)
为元素提供一个ID,然后通过.html()选择文本。我添加了一个代码段进行澄清:
$(document).ready(function (){
var value = $('#label-approve').html();
$('#label-output').html(value);
});
#label-approve {
background: green;
color: white;
}
#label-output {
background: red;
color: white;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span id="label-approve" class="label label-sm label-warning">Approval</span>
<span id="label-output"></span>
答案 1 :(得分:0)
rjcode,您可以尝试执行以下操作:
$('<span class="label label-sm label-warning">Approval</span>').text()