日期:2014-05-18  浏览次数:20423 次

jquery能获取到查询的htm吗,就是获取到它查得到结果的原html
如: $("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().html();
                 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>

------解决方案--------------------
探讨
你没明白我的意思吧
如$("#text1")
要能获取到<input type='text' id='text1' value='test' />