$("#smt").append("<div style='float:left'><table id=\"tablesmtup"+smtc+"\" width=\"50%\" style=\"margin:10px;border:1px solid #000;\"><tr><td><input type=\"button\" onclick=\"removeconpic("+smtc+")\" value=\"移除此项\" /></td></tr><tr><td id=\"smt"+smtc+"\" ></td></tr></table></div>");谁能输出Append  中的html  ,谢谢其中的反斜杠起到什么作用

解决方案 »

  1.   

    反斜杠是转定义字符,"\"hello!\"" 相当于 "'hello!'"
    你这里面没必要用,直接把\"替换为'试试
      

  2.   

    反斜杠是为了转移,避免符号引用的错误。你的代码可以修改为:$("#smt").append("<div style='float:left'><table id=‘tablesmtup"+smtc+"' width='50%' style='margin:10px;border:1px solid #000;'><tr><td><input type='button' onclick='removeconpic('"+smtc+"')' value='移除此项' /></td></tr><tr><td id='smt"+smtc+"' ></td></tr></table></div>");输出试试这样的:$('#smt').find('div').last().html();
      

  3.   

    反斜杠是转义字符,也就是说原样输出,一般是在和关键字符冲突的时候和字符串拼接的时候用得比较多。js输出的代码在页面上是看不到的,你可以用alert() 弹出来看看
      

  4.   


    $("#smt").append('<div style="float:left"><table id="tablesmtup'+ smtc +'" width="50%" style="margin:10px;border:1px solid #000;"><tr><td><input type="button" onclick="removeconpic('+ smtc +')" value="移除此项" /></td></tr><tr><td id="smt'+ smtc +'" ></td></tr></table></div>');
    这样
      

  5.   

    $("#smt").text("<div ...>")   原样输出了   “\”转义