JQUERY:由控件ID查找 [英] JQUERY: Finding by control ID

查看:127
本文介绍了JQUERY:由控件ID查找的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我的aspx页面包含

 <输入类型=文本名称=openid_username/>
<输入类型=文本名称=openid_identifier/>

但现在我想,以取代他们。

 < ASP:文本框ID =openid_username=服务器>< / ASP:文本框>
< ASP:文本框ID =openid_identifier=服务器>< / ASP:文本框>

所以我应该如何修改以下JQUERY,反映输入框,文本框替换?

 变量$ USR = $ this.find(输入[名称= openid_username]');
  VAR的$ id = $ this.find(输入[名称= openid_identifier]');


解决方案

我会使用如该名称被控制在一个容器是错位的属性选择上选择结尾。注意 $ = ,而不是 =

 变量$ USR = $ this.find(输入[名称$ = openid_username]');
VAR的$ id = $ this.find(输入[名称$ = openid_identifier]');

Currently my aspx page contains

<input type="text" name="openid_username" />
<input type="text" name="openid_identifier" />

but now i would like to replace them with

<asp:TextBox ID="openid_username" runat="server"></asp:TextBox>
<asp:TextBox ID="openid_identifier" runat="server"></asp:TextBox>

so how should i modify the following JQUERY, to reflect the input boxes to textboxes replacement?

  var $usr = $this.find('input[name=openid_username]');
  var $id = $this.find('input[name=openid_identifier]');

解决方案

I would use the "ends with" option on the attribute selector in case the name is mangled by the control being in a container. Note the $= instead of =.

var $usr = $this.find('input[name$=openid_username]');
var $id = $this.find('input[name$=openid_identifier]');

这篇关于JQUERY:由控件ID查找的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆