如: $("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>吗
<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>吗
解决方案 »
- datalist如何向上滚动图片
- Fckeditor图片的路径存储问题
- B/S结构:有关上传CAD图纸文件到服务器,如何让用户在程序里可以打开浏览CAD图纸???
- 父页面弹出子页面的同时,为什么父页面的一个TextBox的值却不能正常显示显示出来?
- 【菜鸟求助】密码没错但登陆不成功 userid长度限制?
- 请问超链接打开一个新网页“?”后传输的参数可以用变量表示么?
- 如何实现这个查询功能?
- 如何在超链接里显示数据库里的字段名称.
- 不在VS.NET环境下,怎么把system.windows.forms引入web项目?
- 怎么修复vs.net的帮助?
- 在dreamweaver中设计的html怎么在visual studio 2005中使用
- 【在线等答案】基于asp.net用JQuery动态生成下拉导航条??哪位高人指点下小弟
<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> <script type="text/javascript">
$(function() {
var htmlStr = $("#divAbc").html();
alert(htmlStr);
});
</script>
这个我知道,这个就没获取到<div id="divAbc"></div>我是指原查询的html
不加外层标签也可以,可以这么写
<%@ 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>
没获到什么?$("div")获取的是个对象组。。页面上所有的div的集合
你没明白我的意思吧
如$("#text1")
要能获取到<input type='text' id='text1' value='test' />
那不就是我4楼给你的方法吗?
<%@ 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 html = $('<div>').append($("#text1").clone()).remove().html(); //这就是你要的
alert(html)
});
</script></head>
<body>
<form id="form1" runat="server">
<input type='text' id='text1' value='test' />
</form>
</body>
</html>