0
在appendTo似乎并没有工作类型文本框的情况。(为什么?) 追加代码工作其他地方无法使用append/appendto/innerhtml或任何其他向父div添加输入框。
if($('#'+json.id).length)
也是如此,但在HTML显示不出来。 ㈣一直在这两天:(
这里的
<body>
< div id = "page" >
< div id = "id1" > hello world < input id = "LAPD" > < /div>
< /div>
< /body>
与ID输入= “LAPD” 从生成的我的js代码
switch (json.type) {
case "container":
$('<div id=' + json.id + '/>').appendTo('#' + parent_id);
$('#' + json.id).css({
// container styling
});
break;
case "text":
$('#' + parent_id).text(json.value);
var j = document.createElement('input');
j.id = "LAPD";
j.value = "LAPD"
$(j).appendTo("#"+parent_id);
break;
case "image":
$('<img id=' + json.id + ' src=' + json.value + '/>').appendTo('#' + parent_id);
break;
case "textbox":
var j = document.createElement('input');
j.id = json.id;
j.type = 'text';
$(j).appendTo("#"+parent_id);
if($('#'+json.id).length){
console.log("exists");
}
else{
console.log("doesnt");
}
break;
}
生成的HTML相关的部分案例:“文字”
您需要创建一个[MCVE](/ help/mcve)。基本上,上述作品的相关部分:http://jsbin.com/semetezewu/1 – 2015-03-25 08:24:49
看起来不错 - https://jsfiddle.net/arunpjohny/L9wovxxt/1/ - 看看你的CSS规则 – 2015-03-25 08:26:21
谢谢你的MCVE抬头!新人在这里。但它不适合我。任何想法为什么? (同时在mcve上工作) – user2889561 2015-03-25 09:27:34