我正在为Bootstrap面板编写代码,我想使所选行的标签变为粗体。这是代码:
HTML:
<div id="costCentersList" class="col-md-6 no-padding-right-left">
<div class="panel panel-default no-MP">
<div class="panel-heading">Cost Centers <span class="floatRight"><a href="#" id="newCostCenter" onClick="newCostCenter();">Create New Cost Center</a></span></div>
<div class="panel-body">
<ul>
<li >
<input type="radio" name="costCenter" value="Marketing" id="btnRadioCC1">
<label >Marketing</label> <span class="floatRight">
<input type="button" value="Assign Employees" class="btn btn-primary btnAssignCC btn-rounded-4">
</span></li>
<li>
<input type="radio" name="costCenter" value="Developer" id="btnRadioCC2">
<label>Developer</label><span class="floatRight">
<input type="button" value="Assign Employees" class="btn btn-primary btnAssignCC btn-rounded-4">
</span></li>
</ul>
jQuery:
$('#costCentersList li').on('click',function(){
$('#costCentersList li').removeClass('highlight-row');
$(this).addClass('highlight-row');
var abc = $(this).find('label');
$('abc').attr('style','font-weight:bold');
})
答案 0 :(得分:0)
确保类highlight-row
具有属性:font-weight:bold
。
并将函数内容替换为:
$('#costCentersList li label').removeClass('highlight-row');
$(this).find('label').addClass('highlight-row');