我有引導的標籤,我想根據這些標籤被激活,纔有可能做到這一點在這裏使用jQuery更改表格值是我的javascript獲取類,並檢查該div有活動類
$(document).ready(function() {
$('.tab').click(function() {
var value_ch = $('.tabe-pane.active').attr('id');
$('#valuechange').val(value_ch);
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" id='ma' href="#ma"><i class="fa fa-mobile"></i> Home</a></li>
<li><a data-toggle="tab" class='tab' href="#otc"><i class="fa fa-bank"></i> change test</a></li>
</ul>
<div class="tab-content">
<div id="ma" class="tab-pane fade in active">
<h3>First Value</h3>
</div>
<div id="otc" class="tab-pane fade">
<h3>Second tab</h3>
</div>
</div>
<input type="text" id="valuechange" value="" />
任何一個可以幫助我,當我點擊輸入字段的值是不會改變
你有一個錯字; '.tabe-pane.active'應該是'.tab-pane.active' – George