使用 javascript 获取 LinkBut​​ton 文本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4406630/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 11:19:22  来源:igfitidea点击:

Get LinkButton text using javascript

javascriptasp.netlinkbutton

提问by Fire Hand

How can i get the text of LinkButton in .NET using javascript?

如何使用 javascript 在 .NET 中获取 LinkBut​​ton 的文本?

Tried .innerHTMl, .innerText, .value...all not working....

试过 .innerHTMl, .innerText, .value...都不起作用....

采纳答案by Ghyath Serhal

document.getElementById('lnk1').innerText 

this should solve your problem, i tried it now and it works.
can you show me your code.

这应该可以解决你的问题,我现在试过了,它有效。
你能告诉我你的代码吗?

回答by sam

for server side control use ClientID.

对于服务器端控制使用 ClientID。

document.getElementById('<%= lnk1.ClientID %>').innerText

works for asp.net server side controls.

适用于 asp.net 服务器端控件。