在页面中,创建一个IMG标记,用于显示一幅图片;单击该图片时,在其右侧通过clone()方法复制一幅图片。
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>复制元素节点title> <script type="text/javascript" src="Jscript/jquery-1.4.2.js"> script> <script type="text/javascript" src="Jscript/jquery-1.4.2-vsdoc.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="封面" src="Images/img04.jpg" />span> body> html>
页面效果: