我的视图中有以下按钮:
<button type="button" class="btn btn-lg btn-primary">Primary button</button>
disabled
如果仅在满足特定条件的情况下,我想向其添加属性true
。我如何以一种优雅的方式?
您应该通过以下两种或多种方式进行操作:
<button type="button" class="your-class btn btn-lg btn-primary">Primary button</button>
<script type="text/javascript">
$(function(){
if(Condition){
$('.your-class').addClass('disabled');
}
});
</script>
OR
In The rails term
<button type="button" class="btn btn-lg btn-primary <%= conditon ? "disabled" : ""%>">Primary button</button>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句