简体   繁体   English

如何使用JavaScript从ASP.NET文本框中获取自定义属性?

[英]How to get Custom Property from ASP.NET Textbox using javascript?

我已经创建了一个自定义文本框,其属性为“ key”(ASP.NET C#)。我想使用Java脚本获取此属性“ key”的值。我该怎么做?

Not sure what you are asking. 不知道你在问什么。

if you have a textbox rendered like so: 如果您有一个这样呈现的文本框:

<input type="text" id="foo" key="somekey" text="Hello" />

You could get the value of "key" in JS like so: 您可以像这样在JS中获得“键”的值:

document.getElementById('foo').getAttribute('key')

If you are using jquery than for this will help you. 如果您使用的是jQuery,那么这将对您有所帮助。

$("#tb1").attr("key")

for this textbox 对于此文本框

<input type="text" id="tb1" key="mykey" text="" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM