惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
Netflix TechBlog - Medium
Blog — PlanetScale
Blog — PlanetScale
月光博客
月光博客
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
爱范儿
爱范儿
量子位
博客园 - 聂微东
Engineering at Meta
Engineering at Meta
WordPress大学
WordPress大学
GbyAI
GbyAI
MyScale Blog
MyScale Blog
IT之家
IT之家
P
Proofpoint News Feed
M
MIT News - Artificial intelligence
The Cloudflare Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Hugging Face - Blog
Hugging Face - Blog
The Register - Security
The Register - Security
Microsoft Security Blog
Microsoft Security Blog
博客园_首页
MongoDB | Blog
MongoDB | Blog
F
Fortinet All Blogs
博客园 - 三生石上(FineUI控件)
Y
Y Combinator Blog
雷峰网
雷峰网
V
Visual Studio Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Last Week in AI
Last Week in AI
博客园 - 叶小钗
D
DataBreaches.Net
B
Blog
B
Blog RSS Feed
大猫的无限游戏
大猫的无限游戏
aimingoo的专栏
aimingoo的专栏
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
The GitHub Blog
The GitHub Blog
云风的 BLOG
云风的 BLOG
Recent Announcements
Recent Announcements
阮一峰的网络日志
阮一峰的网络日志
小众软件
小众软件
腾讯CDC
T
Threat Research - Cisco Blogs
SecWiki News
SecWiki News
Martin Fowler
Martin Fowler
D
Docker
Cisco Talos Blog
Cisco Talos Blog
T
Tenable Blog
Webroot Blog
Webroot Blog
宝玉的分享
宝玉的分享

博客园 - LeeXiaoLiang

自己写的一个javascript下拉列表类 jquery向.ashx文件post中文乱码问题的解决 【转】通过在RowDataBound事件中把行索引绑定到控件的CommandArgument,然后在RowCommand事件中取出 - LeeXiaoLiang - 博客园 【转】GridView的RowCommand事件中取得行索引 - LeeXiaoLiang - 博客园 【转】GridView 实现服务器端和客户端全选的两种方法 ASP.NET之GridView数据绑定 - LeeXiaoLiang - 博客园 希尔排序的C语言实现(2) 希尔排序的C语言实现(1) 简单插入排序的C语言实现 堆排序的C语言实现 对于堆排序算法的理解 【转】sqlserver中分页方法集锦 【转】高效的MySQL分页 【摘】完全二叉树 【原创】连接字符串数组 【摘】用C实现将数组转换为字符串 【原创】用C实现Trim()函数 - LeeXiaoLiang - 博客园 【转】浅谈数据库设计技巧 [转]数据库设计范式的理解
jquery1.5.1根据元素ID获取元素对象
LeeXiaoLiang · 2011-04-01 · via 博客园 - LeeXiaoLiang

尽管听说jquery的大名几年了,但是一直没有使用过。这两天想在项目中使用被一些小细节折腾的够呛,看来jquery没有传说中的那么好学。在jquery1.5.1根据ID来获取对象返回的是对应数组,想不通怪不得使用document.getElementById(""ID名"")可以取到单一的对象,使用$("#ID名")却不行,悲剧呀。

View Code

<!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>
  
<title> 选择器测试 </title>
  
<style type="text/css">
   .txtobj
{background-color: #6600FF;}
  
</style>
  
<script type="text/javascript" src="../jquery-1.5.1.min.js"></script>
  
<script language="JavaScript" type="text/javascript">
  $(document).ready(
     
function()
     {
        $(
"input[type='text']")
        .click
        (
           
function()
           {
             
this.value=$("#lblMsg")[0].innerText;
           }
        )
        .keydown(
        
function()
        {
            alert($(
"#divTest")[0].innerText);
            alert($(
"#lblMsg")[0].innerHTML);
            alert($(
"#txtTest")[0].value);
            
return false;
        }
        );
     }
  );
  
</script>
 
</head><body>
    
<table width="400" border="1" cellpadding="0" cellspacing="0">
       
<tr>
          
<td><span id="lblMsg">0123456789</span></td>
       
</tr>
       
<tr>
          
<td>
             
<input type="text" id="txtTest" class="txtobj" value="@#$message test"/>
          
</td>
       
</tr>
    
</table>
    
<div id="divTest">ABCDEFGHIJKLMNOPQRSTUVWXYZ</div>  
 
</body>
</html>