看板 Web_Design 關於我們 聯絡資訊
※ 引述《PsMonkey (痞子軍團團長)》之銘言: : 打廣告順便問問題 : 原 po 可參考 : http://pt2wiki.twbbs.org/Wiki.jsp?page=JS_AddDelElementInOnePage : 我想問的是 : 用這種方法產生 radio : 在 IE(還是 Fx 有點忘了)下會沒辦法點選 : 不知道有沒有人可以指點一二 Orz IE 6.0以下版本適用 http://boogie.javaeye.com/blog/26917 http://blog.roodo.com/rocksaying/archives/1848520.html 其實這兩篇是一樣的作法... ──────────────────────────────── 話說說到創立元素的話,我會比較喜歡用底下這個。 function elem(name, attrs, style, text,eventstr) { var e = document.createElement(name); if (attrs) { for (key in attrs) { if (key == 'class') e.className = attrs[key]; else if (key == 'id') e.id = attrs[key]; else e.setAttribute(key, attrs[key]); } } if (style) for (key in style) e.style[key] = style[key]; if (text) e.appendChild(document.createTextNode(text)); if (eventstr) for (key in eventstr) e.setAttribute(key, new Function(eventstr[key])); //修正錯誤 21:12 return e; } 它的使用範例大概就像 var em=elem('select',{name:'cc'+num,id:'cc'+num},'','',''); 通用性廣... ──────────────────────────────── 這網頁有一些對dom操作的技巧, http://www-128.ibm.com/developerworks/tw/library/x-matters41.html 也是上述function的原出處。(event是後來自己加上去的。:P) -- String temp="relax"; | Life just like programing while(buringlife) String.forgot(temp); | to be right or wrong while(sleeping) brain.setMemoryOut(); | need not to say stack.push(life.running); | the complier will stack.push(scouting.buck()); | answer your life stack.push(bowling.practice()); | Bone everything -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.134.27.68 ※ 編輯: TonyQ 來自: 220.134.27.68 (01/20 21:07)
PsMonkey:感謝... 雖然... 不想用這種鳥招 XDXD 01/20 22:30
grassboy2:看起來很直觀耶~這支函數在IE7和FF就不支援了嗎? 01/21 10:40
yaca:感謝各位.....問題解決了 01/21 12:48
TonyQ:我說的是 前兩個連結內的解法是IE6以下適用 囧 01/21 17:36