使用javascript生成分组复选框JQuery mobile(Generate grouped checkboxes JQuery mobile with javascript)

编程入门 行业动态 更新时间:2024-10-27 06:23:46
使用javascript生成分组复选框JQuery mobile(Generate grouped checkboxes JQuery mobile with javascript)

请检查此代码: http : //jsfiddle.net/Hce8y/

我正在尝试生成一个分组复选框列表:

function ItemCode_Changed(sender, onload) { $('#category-contianer-id-3').append( '<div data-role="fieldcontain">' + '<fieldset data-role="controlgroup">' + '<legend>Choose as many:</legend>' + '<input type="checkbox" name="checkbox-1a" id="checkbox-1a" class="custom" />' + '<label for="checkbox-1a">Cheetos</label>' + '<input type="checkbox" name="checkbox-2a" id="checkbox-2a" class="custom" />' + '<label for="checkbox-2a">Doritos</label>' + '<input type="checkbox" name="checkbox-3a" id="checkbox-3a" class="custom" />' + '<label for="checkbox-3a">Fritos</label>' + '<input type="checkbox" name="checkbox-4a" id="checkbox-4a" class="custom" />' + '<label for="checkbox-4a">Sun Chips</label>' + '</fieldset>' + '</div>'); $('#category-contianer-id-3 [data-role="fieldcontain"]').fieldcontain(); $('#category-contianer-id-3 [data-role="fieldcontain"]').fieldcontain('refresh'); $("#category-contianer-id-3 input[type='checkbox']").checkboxradio(); $("#category-contianer-id-3 input[type='checkbox']").checkboxradio('refresh'); //$('#my-home').page();

}

当更改输入中的文本时,但结果看起来不像演示。

有任何错误,任何帮助表示赞赏。

Please check this code: http://jsfiddle.net/Hce8y/

I'm trying to generate a list of grouped check boxes:

function ItemCode_Changed(sender, onload) { $('#category-contianer-id-3').append( '<div data-role="fieldcontain">' + '<fieldset data-role="controlgroup">' + '<legend>Choose as many:</legend>' + '<input type="checkbox" name="checkbox-1a" id="checkbox-1a" class="custom" />' + '<label for="checkbox-1a">Cheetos</label>' + '<input type="checkbox" name="checkbox-2a" id="checkbox-2a" class="custom" />' + '<label for="checkbox-2a">Doritos</label>' + '<input type="checkbox" name="checkbox-3a" id="checkbox-3a" class="custom" />' + '<label for="checkbox-3a">Fritos</label>' + '<input type="checkbox" name="checkbox-4a" id="checkbox-4a" class="custom" />' + '<label for="checkbox-4a">Sun Chips</label>' + '</fieldset>' + '</div>'); $('#category-contianer-id-3 [data-role="fieldcontain"]').fieldcontain(); $('#category-contianer-id-3 [data-role="fieldcontain"]').fieldcontain('refresh'); $("#category-contianer-id-3 input[type='checkbox']").checkboxradio(); $("#category-contianer-id-3 input[type='checkbox']").checkboxradio('refresh'); //$('#my-home').page();

}

when change the text in the input, but the result doesn't looks like the demo.

Is there any mistakes, any help are appreciated.

最满意答案

你必须调用这两种方法:

$('input[type=checkbox]').checkboxradio(); $('fieldset').controlgroup();

更改其子元素后调用fieldcontain()不会改变任何内容。 至少我没有看到任何差异。

You have to call both methods:

$('input[type=checkbox]').checkboxradio(); $('fieldset').controlgroup();

Calling fieldcontain() after changing its child-elements doesn't change anything. At least I was not able to see any differences.

更多推荐

>',type,check,电脑培训,计算机培训,IT培训"/> <meta name="descrip

本文发布于:2023-07-29 05:07:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1312617.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:复选框   JQuery   javascript   mobile   checkboxes

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!