clone()方法用于复制一个元素,但是被复制出来的元素不具备复制的功能,如果希望被复制出来的元素也具备复制的功能,需要给clone()方法加上true这个参数,即clone(true).

例如:

<!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>
<meta charset="UTF-8">
<script src="http://code.jquery.com/jquery-1.8.0.min.js"></script>
<style type="text/css">
img {
border: solid 1px #ccc;
padding: 3px;
margin: 5px
}
</style>
<script type="text/javascript">
$(function() {
$("img").click(function() {
$(this).clone(true).appendTo("span");
})
})
</script>
</head>

<body> <span><img title="封面" alt="1" src="Images/img04.jpg" /></span> </body>

</html>

clone()与clone(true)的区别的更多相关文章

  1. jQuery中clone和clone(true)的区别

    今天要写的是clone和clone(true)的区别 两者长得很像呀,clone(true)比clone()  多了一个true.看下图白白的牙,笑起来就是这么灿烂.有了true就跟笑起来一样,有了笑 ...

  2. [转]jQuery中clone和clone(true)的区别

    jquery中clone() 和 clone(true)的区别. jquery复制 DOM的时候,原来还可以连 dom上面绑定的事件一起复制. 原文: https://www.cnblogs.com/ ...

  3. jQuery之克隆事件--clone()与clone(true)区别

    clone()与clone(true)同为克隆 clone()表示复制标签本身, clone(true)会将标签绑定的事件一起复制 来看案例: <!DOCTYPE html> <ht ...

  4. 【转载】C#的DataTable类Clone及Copy方法的区别

    在C#中的Datatable类中,Clone方法和Copy方法都可以用来复制当前的DataTable对象,但DataTable类中的Clone方法和Copy方法还是有区别的,Clone方法只复制结构信 ...

  5. bat mvn Maven中-DskipTests和-Dmaven.test.skip=true的区别 Maven 生命周期

    cd C:\Users\lt32806\git\tempest call mvn clean compile -Dmaven.test.skip=truepause Maven中-DskipTests ...

  6. git & github & git clone & 'git clone' failed with status 128

    git & github & git clone & 'git clone' failed with status 128 'git clone' failed with st ...

  7. HTTPS clone !== SSH clone

    HTTPS clone !== SSH clone https clone bug SSH clone OK testing SSH key https://www.cnblogs.com/xgqfr ...

  8. clone()与clone(true)的用法

    clone() 方法生成被选元素的副本,包含子节点.文本和属性. 使用 clone(true) 方法在clone()的基础上还包括克隆元素的事件处理器.

  9. 从gitlab或者github采用git clone和download zip的区别

    不要做伸手党啊大兄弟,这种问题自己稍加理解就知道答案了,实在想不到就上谷歌搜一下嘛,比如这个:git - Github: difference between Clone in desktop and ...

随机推荐

  1. jquery模板制作左侧导航组件

    /** * Created by bmk on 16-4-25. * * 用法:在自己的js里面把左侧导航的相关图标和对应的列表项名称如下编写: * 版本更新日至按需添加 * 在js中的RNA.run ...

  2. POJ 3321 Apple Tree(树状数组)

                                                              Apple Tree Time Limit: 2000MS   Memory Lim ...

  3. Generator 函数学习笔记

    // 使用 function* 定义一个 generator 函数 function* helloWorldGenerator() { yield 'hello'; // yield 关键字作为暂停的 ...

  4. SQL Server DBA日常运维语句

    1.检查数据库完整性 dbcc checkdb(Portal) 检查数据库完整性checkdb Portal的 DBCC 结果. Service Broker 消息 9675,状态 1: 已分析的消息 ...

  5. Intel DPDK的一些参资料

    dpdk.org What it is Intel® DPDK is a set of libraries and drivers for fast packet processing on x86 ...

  6. 51nod 1290 Counting Diff Pairs 莫队 + bit

    一个长度为N的正整数数组A,给出一个数K以及Q个查询,每个查询包含2个数l和r,对于每个查询输出从A[i]到A[j]中,有多少对数,abs(A[i] - A[j]) <= K(abs表示绝对值) ...

  7. bootstrap-轮播图

    <!-- 1.写一个父级,class为carousel slide:添加滑动的效果 data-interval 图片轮播间隔时间,单位ms data-ride="carousel&qu ...

  8. VC中GBK与UTF8转化

    void ConvertGBKToUtf8(CString& strGBK) {    int len=MultiByteToWideChar(CP_ACP, 0, (LPCTSTR)strG ...

  9. 5,SFDC 管理员篇 - 数据模型 - 数据关联

    1,PickList 1,填写基本信息 2, 选择能角色的权限 3,在哪一个层上显示(object 上有多个 Record Type 对应多个层,需要选择在哪一个层显示) 4,Save   2,两个P ...

  10. MXS 编辑器外观

    Tool > Open User Options File # Give symbolic names to the set of colours used in the standard st ...