小编Dar*_*ren的帖子

使用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">
Run Code Online (Sandbox Code Playgroud)

因此,当我点击我的文本框时,我希望(例如)使用我标签内的文本进行警告...所以在这种情况下它会提醒"这是我的标签值"

希望有道理:)

jquery jquery-selectors

23
推荐指数
2
解决办法
5万
查看次数

标签 统计

jquery ×1

jquery-selectors ×1