jquery 如何获取整个.select的html代码【续】(内部有js)? 本帖最后由 mingfish 于 2009-09-29 11:30:34 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <script type="text/javascript" src="jquery-1.3.1.js"></script><script>jQuery.fn.extend( { outerHTML: function( replacement ) { if (replacement) { return this.each(function (){ $(this).replaceWith(replacement); }); } var index = $(this).parent().children().index(this); var tmp_node = $("<div>"+$(this).parent().html()+"</div>"); tmp_node.children().not(tmp_node.children().eq(index)).remove(); var up = tmp_node.html(); return up; }}); function getcode(){ $("#codebox").val($(".select").outerHTML()); }</script><div> <div>good</div> <div class="select"> <!-- <script>.....<script> 这部分无法获取,原因可能是$(this).clone()是jquery方法不能克隆js--> <script> function hello(){ alert("hello world"); } </script> <ul> <li>ggg</li> </ul> <span>jjj</span> </div> <div>hello</div></div><textarea id="codebox" style="width:100%;height:300px"></textarea><button onclick="getcode()">get it</button> 怎么样使用JAVASCRIPT做加减乘除运算 JQuery如何实现自定义右键菜单中的复制、粘贴、剪切功能?路过的帮帮忙 Google web地图和web卫星地图位置偏差,如何解决 一个div上放置了一个checkbox,重叠在一起,如何处理单击事件 javascript的验证问题 JS问题 超简单问题,form的提交问题,解决了马上给分 一个促发的滚动效果可以实现吗?? 如何输出radio的值? 谁能给一个输入日期校验的例子和把数字转换成货币显示的例子! js 调用内部函数 有谁能帮帮我的忙啊,打开IE,自动全屏,只有标题栏,工具栏不要!!!求个位大侠啦!
<script>
jQuery.fn.extend( {
outerHTML: function( replacement )
{
if (replacement)
{
return this.each(function (){ $(this).replaceWith(replacement); });
}
var index = $(this).parent().children().index(this);
var tmp_node = $("<div>"+$(this).parent().html()+"</div>");
tmp_node.children().not(tmp_node.children().eq(index)).remove();
var up = tmp_node.html();
return up;
}
});
function getcode(){
$("#codebox").val($(".select").outerHTML());
}
</script>
<div>
<div>good</div>
<div class="select">
<!-- <script>.....<script> 这部分无法获取,原因可能是$(this).clone()是jquery方法不能克隆js-->
<script>
function hello(){
alert("hello world");
}
</script>
<ul>
<li>ggg</li>
</ul>
<span>jjj</span>
</div>
<div>hello</div>
</div>
<textarea id="codebox" style="width:100%;height:300px"></textarea>
<button onclick="getcode()">get it</button>