日期:2014-05-16 浏览次数:20335 次
<script type="text/javascript" src="jquery-1.6.4.min.js" ></script> <script type="text/javascript" > $(document).ready(function() { $(this).click(function(e) { $(e.target).append("<span class='span1'>[newspan]</span>"); }); }) </script>
------解决方案--------------------
<!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> <style> html,body{width:100%;height:100%} </style> </head> <body> <div style="width:400px;height:200px;background-color:#F00;float:right"> <div></div> </div> <div style="width:400px; height:200px; background-color:#F00"></div> <div style="width:400px; height:200px; background-color:#F00;float:right"></div> <input type="button"> <input type="text"> <textarea></textarea> </body> <script> window.onload=function(e){ bindEvent(document.body,'click',function(e){ e=e||event; var obj = e.srcElement || e.target; if(typeof(obj.innerHTML)=='string'){ var div=document.createElement("div"); var x=e.x||e.pageX; var y=e.y||e.pageY; div.style.cssText="position:absolute;left:"+x+"px;top:"+y+"px;"; div.innerHTML="Good"; document.body.appendChild(div); } }); }; function bindEvent(obj,evt,fun) { if(window.addEventListener){ obj.addEventListener(evt, function(e){ fun(e);},false); }else{ obj.attachEvent('on'+evt,fun); } } </script> </html>