使用jQuery查找所选控件或文本框的标签

我想要一些jQuery代码,这将允许我找到一个控件的标签,当我点击文本框…所以在我的HTML我有这个:
<label id="ctl00_WebFormBody_lblProductMarkup"  for="ctl00_WebFormBody_txtPriceAdjustment">This Is My Label Value</label>

<input type="text" style="width:29px;" onclick="alert('label value here');" title="Here is a title" id="ctl00_WebFormBody_txtPriceAdjustment" maxlength="3" name="ctl00$WebFormBody$txtPriceAdjustment">

所以,当我点击我的文本框时,我想(例如)使用我的标签内的文本来做一个警报,所以在这种情况下,它会提醒“这是我的标签值”

希望有意义:)

解决方法

DEMO
$('input').focus(function(){
   var $myLabel = $('label[for="'+ this.id +'"]');
   // Here do something with $myLabel element
});

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: &lt;span id=&quot...
jQuery 添加水印 &lt;script src=&quot;../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...