用于在文本框的click事件上显示列表框的javascript [英] javascript for displaying listbox on click event of textbox

查看:92
本文介绍了用于在文本框的click事件上显示列表框的javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨...
我正在创建一个用户控件,希望在其中使用JavaScript使用文本框的单击事件使列表框可见.

我无法使用getElementByID属性获取列表框的ID.它返回null.

请帮助...

hi...
I am making a user control in which I want to make a listbox visible on click event of a textbox using javascript.

I am not able to get id of listbox using getElementByID property. It is returning null.

Please Help...

推荐答案

你好,

getElementByID应该是getElementById


javascript区分大小写
hello,

getElementByID should be getElementById


javascript is case sensitive


我无法使用getElementByID属性获取列表框的ID.它返回null."
我不知道从哪里开始,因为他的问题太多了.

第一:您无法通过getElementById获取ID.这是您通过其HTML属性"id"获取的DOM元素.
第二:getElementById不是属性,而是函数. (当然可以说getElementById是一个javascript对象的属性,有时绑定到一个函数,该函数通过其id返回DOM元素.)
第三:ASP标签的服务器端ID属性与客户端HTML标签属性ID无关.如果要获取ASP.Net控件的客户端ID,则必须使用属性ClientId

希望这可以帮助您解决此问题.

最好的问候,

—MRB
"I am not able to get id of listbox using getElementByID property. It is returning null."
I don''t know where to start as there is so much wrong about his question.

First: You don''t get the id via getElementById. It''s the DOM element you fetch via it''s HTML attribute "id".
Second: getElementById isn''t a property, but rather a function. ( One could argue of course that getElementById is a javascript object''s property that is sometimes bound to a function which returns a DOM element by it''s id.)
Third: The server side id property of an ASP tag has nothing to do with the client side HTML tag attribute id. If you want to fetch the client side id of an ASP.Net control, you have to use the property ClientId

Hope this helps you sort this out.

Best Regards,

—MRB


这篇关于用于在文本框的click事件上显示列表框的javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆