1
我没有早期的jQuery移动体验,现在我正尝试在javascript中动态添加新复选框。jQuery手机:动态添加复选框
使用(在HTML头)HTML的
jquery.mobile-1.4.5.min.css
jquery-1.11.3.min.js
jquery.mobile-1.4.5.min.js
部分:JAVASCRIPT的
<form>
<fieldset data-role="collapsible">
<div id="agree" data-role="controlgroup"></div>
<input type="submit" value="Submit">
</fieldset>
</form>
部分:
var html = '<input type="checkbox" name="checkbox-1" id="checkbox-1" /><label for="checkbox-1">I agree</label>';
$('#agree').html(html);
$("input[type='checkbox']").checkboxradio("refresh");
我只得到纯复选框,没有任何格式。 有什么不对?我错过了什么吗?
请您分享一个工作片段,也许JSFiddle,以便我们知道您正在使用哪个版本的JQuery? –
这里有一些完整的工作示例:[在jQuery Mobile中动态创建带有复选框的产品列表](https://stackoverflow.com/questions/41325900/dynamically-creating-productlists-with-checkboxes-in-jquerymobile-proves-difficu/41484070 #41484070)和在这里:[Jquery Mobile checkbox-list在添加项目和更新时不更新:“刷新”脚本样式](https://stackoverflow.com/questions/41404047/jquery-mobile-checkbox-list-没有更新时添加项目和刷新t/41409019#41409019) – deblocker