<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="https://www.jb51.net/js/Model.js"></script> <script src="https://www.jb51.net/js/Utile.js"></script> <script src="https://www.jb51.net/js/UIComponent.js"></script> </head> <body> <script> document.addEventListener(RES.DATA_FINISH_EVENT,init); RES.init(["new_icon"],"img/","xml"); var arr=["北京","上海","广州","深圳","成都"]; function init() { document.addEventListener("change",changeHandler); var elem=document.createDocumentFragment(); for(var i=0;i<arr.length;i++){ var radio=new Radio(elem); radio.label=arr[i]; if(i===0){ radio.checked=true; } } document.body.appendChild(elem); } function changeHandler(e) { console.log(e); } Model.instance.elem.addEventListener("chi",chiHandler); Model.instance.elem.dispatchEvent(new Event("chi")); function chiHandler(e) { console.log(e) } </script> </body> </html>
JS面向对象之单选框实现(2)
内容版权声明:除非注明,否则皆为本站原创文章。
转载注明出处:http://www.heiqu.com/18467b62a9a990625c1099b27a802169.html