我对这一句话有点胡思乱想:
jQuery("#image-div").html("<img src='get.php?id_no='" + id + ">");我尝试将<img>标记与变量id连接起来,但似乎无法正确使用引号。我知道这是个愚蠢的错误,但我就是不明白。能帮我个忙吗?
发布于 2013-03-03 13:11:07
看起来你把撇号放错地方了。
jQuery("#image-div").html("<img src='get.php?id_no=" + id + "'>");发布于 2013-03-03 13:14:13
您的代码中有一个放错位置的单引号。
jQuery("#image-div").html("<img src='get.php?id_no='" + id + ">");
// ^ This one here它应该是
jQuery("#image-div").html("<img src='get.php?id_no=" + id + "'>");
// ^ Should be here发布于 2013-03-03 16:41:43
我真的不希望创建像你这样的DOM元素应该很严格,比如:
jQuery("#image-div").appendTo(
$("<img/>")
.attr("src", "get.php?id_no" + id)
.attr("alt", "someThing") )我知道它更多的是打字,但现在更有意义了。
https://stackoverflow.com/questions/15182658
复制相似问题