---
title: "jquery 扩展 outerHTML"
author: "dh189"
date: "2010-07-20T09:45:33Z"
tags: []
categories: ["Web前端"]
slug: "jquery-outerhtml"
draft: false
lastmod: "2010-07-20T09:45:33Z"
id: 716655
url: "https://dh189.iteye.com/blog/716655"
---

```java

jQuery.fn.outerHTML = function(s) {
	return (s)? this.before(s).remove(): jQuery("<p>").append(this.eq(0).clone()).html();
}

```

使用如下：

```java

alert($("#test").outerHTML());

```