如何从字符串控件ID中获取javascript中的元素? [英] how to getElementById in javascript from string control id?
本文介绍了如何从字符串控件ID中获取javascript中的元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好朋友,
我从代码后面发送字符串类型TextBox控件id到javascript函数。我需要在javascript中找到textBox对象,我可以使用.focus()方法
如何获取这个?
hello friends,
I am sending string type TextBox control id from code behind to javascript function. I need to find the textBox object in javascript in which i can use .focus() method
how to get this ?
推荐答案
你不需要发送它 - 使用内联服务器标签...
You need not send it nowhere - use inline server tags...
<script>
var el = document.getElementById('<%= MyTextBox.ClientID %>');
if(el) el.focus();
</script>
请参阅
http://www.w3schools.com/jsref/met_doc_getelementbyid.asp [ ^ ]
这篇关于如何从字符串控件ID中获取javascript中的元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文