我正面临一个非常奇怪的问题。这里是我的代码:?jQuery(Mobile):按钮不隐藏
<div id="status">
<div id="armStatus">
<div id="armText">
<fieldset data-role="controlgroup">
<legend>Unit</legend>
<input type="checkbox" class="CB" name="armCB_1" id="armCB_1" class="custom" data-mini="true" />
<label for="armCB_1">Arming Status</label>
<p id="armingtext"></p>
</fieldset>
</div>
</div>
<table class="config" id="status_table">
<thead>
<tr>
<th colspan="4"; style= "padding-bottom: 20px; color:#6666FF; text-align:left; font-size: 1.5em">Feedback Status</th>
</tr>
<tr>
<th>Index</th>
<th>Feedback Type</th>
<th>Feedback Number</th>
<th>Status</th>
<th class="cHide">Monitor?</th>
<th class="cHide">Remove?</th>
</tr>
</thead>
<tbody>
<tr>
</tr>
</tbody>
</table>
<button type="button" id="monitor" class="cHide" data-role="button" data-mini="true" data-transition="fade">Monitor</button>
</div>
如上图,按钮monitor
是具有相同类.cHide
为2表头monitor?
和“删除'。但是当这种被称为:
$(".cHide").hide();
只有monitor?
和remove?
列被隐藏,但monitor
按钮仍然存在。 这是为什么呢?怎么了?
编辑:似乎它的工作正常,如果它是独立的。我怀疑是否因为
$('#monitor').button('enable');
放置在什么地方?
此处,我隐藏和显示.cHide
(这是在的document.ready)的部分代码
$('.done').click(function(){
$('#n_keypad').hide();
login_code = $('#myInput').val();
$.post('/login' , {passcode:login_code.toString()})
.done(function(reply) {
$("#login_div").hide();
alert("You are login as " + reply);
if (reply=="engineer"){
$("#securityMode").show();
$("#labels").show();
$("#status").show();
$("#display").show();
$("#logoutbutton").show();
$(".cHide").show();
$("#loginbutton").hide();
$("#configtable").hide();
}
else if(reply=="user"){
$("#securityMode").show();
$("#configtable").show();
$("#logoutbutton").show();
$("#labels").hide();
$("#status").show();
$("#display").hide();
$("#configeditdiv").hide();
$(".cHide").hide();
}
您是否使用调试器检查了'$(“。cHide”)'的值?代码看起来不错。 – Jan
你的代码工作正常 - http://jsfiddle.net/JY2ub/。这是外面的东西,会导致问题。 – lifetimes
你使用任何UI框架?像jQuery UI或手机等。 – asifrc