2012-02-26 62 views
0

我正在设计一个笔记应用程序,并且在使用JQuery添加多个笔记时遇到了问题。我设计的方式相对简单,在粘滞便笺的图像上叠加了一个文本框。为了生成新的笔记,这里是我用于图像的代码。JQuery添加一个HTML文本框

function addEvent() { 
var ni = document.getElementById('myDiv'); 
var numi = document.getElementById('theValue'); 
var num = (document.getElementById("theValue").value -1)+ 2; 
numi.value = num; 
var divIdName = "my"+num+"Div"; 
var newdiv = document.createElement('div'); 
newdiv.setAttribute("id",divIdName); 
newdiv.prepend = "<img src='Sticky_Note.png'</a>"; 
ni.appendChild(newdiv); 
var newtext = document.createElement('Note') 
newdiv.prepend = "<input type="textarea" rows="3" cols="25" x-webkit-speech="x-webkit-  speech" style="width:380px;height:300px; background: none; border:none; font-size:24px; color:#0033FF;font-family:comic sans ms " />"; 
ni.appendChild(newtext); 

但是文本框不显示! 我应该怎么做才能修复它?

+0

It's plain Javascript。no jQuery at – gdoron 2012-02-26 00:28:45

+0

put the associated html too – uday 2012-02-26 00:30:24

回答

0

如果是这样的原代码,这可能您的问题:

"<input type="textarea" rows="3" cols="25" x-webkit-speech="x-webkit-  speech" style="width:380px;height:300px; background: none; border:none; font-size:24px; color:#0033FF;font-family:comic sans ms " />"; 

您使用qoute内qoute。您可能要改变“以”

"<input type='textarea' rows='3' cols='25' x-webkit-speech='x-webkit-  speech' style='width:380px;height:300px; background: none; border:none; font-size:24px; color:#0033FF;font-family:comic sans ms ' />"; 
0

你有一个图像标记(开口),而不关闭你的形象:

newdiv.prepend = "<img src='Sticky_Note.png'</a>"; 

@Dandroid已经引起了你的报价问题..