- function create(parentId,eleType,eleName,eleId,eleValue){
- var board = document.getElementById(parentId);
- var e = createElement("input",eleName);
- e.type = eleType;
- e.id = eleId;
- e.value = elevalue;
- board.appendChild(e);
- //设置选中
- e.setAttribute("checked","checked");
- //添加文字
- board.appendChild(document.createTextNode("Item"));
- }
- function createElement(type, name) {
- var element = null;
- try {
- // First try the IE way; if this fails then use the standard way
- element = document.createElement_x('<'+type+' name="'+name+'">');
- } catch (e) {
- // Probably failed because we’re not running on IE
- }
- if (!element) {
- element = document.createElement(type);
- element.name = name;
- }
- return element;
- }
转载于:https://www.cnblogs.com/hannover/p/4181798.html