如: $("div")
页面中有5个div
<div>sdfsfsdf</div>
<div style='color:red;'>sdfsfsdf</div>
<div style='font-size:18px;'>sdfsfsdf</div>
<div style='colr:blue;'>sdfsfsdf</div>
<div>sdfsfsdf</div>
,能获取到
<div>sdfsfsdf</div>
<div style='color:red;'>sdfsfsdf</div>
<div style='font-size:18px;'>sdfsfsdf</div>
<div style='colr:blue;'>sdfsfsdf</div>
<div>sdfsfsdf</div>吗
------解决方案--------------------------------------------------------
LS很速度!!
------解决方案--------------------------------------------------------
不加外层标签也可以,可以这么写
- HTML code
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %><!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 runat="server"> <title>无标题页</title> <script src="jquery-1.4.1-vsdoc.js" type="text/javascript"></script> <script type="text/javascript"> $(function() { var $div = $("div"); $div.each(function() { var html = $('<div>').append($(this).clone()).remove()(); alert(html) }); }); </script></head><body> <form id="form1" runat="server" > <div>sdfsfsdf</div><div style='color:red;'>sdfsfsdf</div><div style='font-size:18px;'>sdfsfsdf</div><div style='colr:blue;'>sdfsfsdf</div><div>sdfsfsdf</div> </form></body></html>
------解决方案--------------------------------------------------------