gpt4 book ai didi

javascript - 平面 UI 复选框样式在启动时不应用

转载 作者:行者123 更新时间:2023-11-28 04:17:50 31 4
gpt4 key购买 nike

我正在使用 http://designmodo.github.io/Flat-UI/ 中的扁平 UI

我复制了复选框示例页面中的所有文件和代码。

但是我注意到该复选框并未显示为样式复选框,但在我单击初始化按钮手动应用 js 后,它将显示为样式复选框。

代码:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Daily Tracker Settings</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<!-- Loading Bootstrap -->
<link href="../dist/css/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">

<!-- Loading Flat UI -->
<link href="../dist/css/flat-ui.min.css" rel="stylesheet">

<link rel="shortcut icon" href="img/favicon.ico">
</head>
<body>
<form id="form1" runat="server" role="form">
<div class="container">
<div class="row mbl">
<div class="col-md-12">
<h4>Plugin methods</h4>
</div>
<div class="col-md-12">
<form role="form">
<div class="form-group">
<label class="checkbox" for="checkbox100">
<input type="checkbox" data-toggle="radio" value="" id="checkbox100" required>
Checkbox

</label>
</div>
<button type="submit" class="btn btn-sm btn-primary">Submit</button>&nbsp;&nbsp;&nbsp;&nbsp;

<button class="btn btn-sm btn-default" data-radiocheck-check="#checkbox100">Check</button>
<button class="btn btn-sm btn-default" data-radiocheck-uncheck="#checkbox100">Uncheck</button>
<button class="btn btn-sm btn-default" data-radiocheck-toggle="#checkbox100">Toggle</button>&nbsp;&nbsp;&nbsp;&nbsp;

<button class="btn btn-sm btn-default" data-radiocheck-indeterminate="#checkbox100">Indeterminate</button>
<button class="btn btn-sm btn-default" data-radiocheck-determinate="#checkbox100">Determinate</button>&nbsp;&nbsp;&nbsp;&nbsp;

<button class="btn btn-sm btn-default" data-radiocheck-disable="#checkbox100">Disable</button>
<button class="btn btn-sm btn-default" data-radiocheck-enable="#checkbox100">Enable</button>&nbsp;&nbsp;&nbsp;&nbsp;

<button class="btn btn-sm btn-default" data-radiocheck-destroy="#checkbox100">Destroy</button>
<button class="btn btn-sm btn-default" data-radiocheck-init="#checkbox100">Init</button><br>
<br>
</form>
</div>
</div>
<!-- /.row -->

</div>


<!-- jQuery (necessary for Flat UI's JavaScript plugins) -->
<script src="../dist/js/vendor/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="../dist/js/vendor/video.js"></script>
<script src="../dist/js/flat-ui.min.js"></script>

<script>
$('button:not([type="submit"])').on('click', function (e) {
var $this = $(this);

if (!!$this.attr('data-radiocheck-check')) {
var el = $this.attr('data-radiocheck-check');
$(el).radiocheck('check');
} else if (!!$this.attr('data-radiocheck-uncheck')) {
var el = $this.attr('data-radiocheck-uncheck');
$(el).radiocheck('uncheck');
} else if (!!$this.attr('data-radiocheck-toggle')) {
var el = $this.attr('data-radiocheck-toggle');
$(el).radiocheck('toggle');
} else if (!!$this.attr('data-radiocheck-indeterminate')) {
var el = $this.attr('data-radiocheck-indeterminate');
$(el).radiocheck('indeterminate');
} else if (!!$this.attr('data-radiocheck-determinate')) {
var el = $this.attr('data-radiocheck-determinate');
$(el).radiocheck('determinate');
} else if (!!$this.attr('data-radiocheck-disable')) {
var el = $this.attr('data-radiocheck-disable');
$(el).radiocheck('disable');
} else if (!!$this.attr('data-radiocheck-enable')) {
var el = $this.attr('data-radiocheck-enable');
$(el).radiocheck('enable');
} else if (!!$this.attr('data-radiocheck-destroy')) {
var el = $this.attr('data-radiocheck-destroy');
$(el).radiocheck('destroy');
} else if (!!$this.attr('data-radiocheck-init')) {
var el = $this.attr('data-radiocheck-init');
$(el).radiocheck();
}

e.preventDefault();
});

</script>
</form>
</body>
</html>

最佳答案

使用该样式手动初始化所​​有复选框会正确创建复选框。不确定为什么在来源的示例中他们不必这样做

<script>
$(document).ready(function () {
$(':checkbox').radiocheck();
});
</script>

关于javascript - 平面 UI 复选框样式在启动时不应用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45686570/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com