纽扣

<button type="button" class="btn" onclick="CountClass()" runat="server" data-toggle="modal" data-target="#inlineForm1">OPEN</button>


情态的

<div class="modal fade text-left" id="inlineForm1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel34" aria-hidden="true">
some code
</div>


JavaScript:

function CountClass() {
   if(some code){
      $('#inlineForm1').modal('hide');
   }
}


为什么不起作用?

最佳答案

您没有说if表达式需要是什么,所以我没有解决这个问题,但是要使用jQuery隐藏某些内容,您可以在选择的元素上使用.hide()即可。

$('#inlineForm1').hide();

在幕后,这会将style="display:none"添加到元素中,而相反的.show()将其删除。知道了这一点,您还可以使用CSS覆盖行为或以一种状态或另一种状态启动它。

10-05 19:45