首页 > 应用开发 > > jquery关于appendTo问题
为何两种方式获取的元素插入span中图片显示位置不一样?<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>动态插入节点方法</title>
<script type="text/javascript"
src="Jscript/jquery-1.8.2.min.js">
</script>
<style type="text/css">
body{font-size:13px}
img{border:solid 1px #ccc;padding:3px;margin:5px}
</style>
<script type="text/javascript">
$(function() {
$("img").appendTo($("span")); //插入内容
$("#img1").appendTo($("span")); //插入内容
})
</script>
</head>
<body>
<img id="img1" title="2008年新书封面" src="" />
<span><img title="2010年新书封面" src="" /></span>
</body>
</html>来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/3598/viewspace-3131785/ ,如需转载,请注明出处,否则将追究法律责任。