ITPub博客

首页 > 应用开发 > > jquery关于appendTo问题

jquery关于appendTo问题

作者:zzzhangyi 时间:2019-08-14 16:42:04 0 删除 编辑

为何两种方式获取的元素插入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/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-08-14

  • 博文量
    133
  • 访问量
    947