如何添加getElementById(id)? [英] How to add getElementById(id)?

查看:87
本文介绍了如何添加getElementById(id)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,
我有一个html按钮和文本框.至于文本框的内容,我想继续使用鼠标按钮.我想我想知道他们错在哪里了吗?

 <%@    页面   语言  ="  VB"  AutoEventWireup    false"  CodeFile   ="  继承   _ Default"   %> 
<  !DOCTYPE     html     PUBLIC    -//W3C//DTD   XHTML     1.0    过渡//EN" " http://www.w3. org/TR/xhtml1/DTD/xhtml1-transitional.dtd" <   html     ="   http://www.w3.org/1999/xhtml" > 
<      ="  服务器" <  标题 >  <  /title  > 
<  脚本    ="  文本/javascript" 函数 getir(id){
    alert(文档 .getElementById(id).Value);

    }
<  / 脚本 > 
<  /head  > 
<  正文 > 
    <  表单    ="   form1"  runat   >服务器"  > 
    <   div  > 
        <   asp:TextBox     ID   ="   runat   服务器" <  > 

    <  /div  > 
    <  /form  > 
    <   p  > 
        <  输入    ="   Button1" 类型  按钮"     =" 按钮" 鼠标悬停   getir('<% = txt.ClientID    / >  <  /p  > 
<  /body  > 
<  /html  >  

解决方案

您尚未告知错误,但请尝试:
alert(document.getElementById(id).value);


JavaScript是区分大小写的语言..

alert(document.getElementById(id).value);



试试这个.


Hello,
I have got a html button and textbox. As for the contents of the textbox I want to get on with the mouse button. I guess I wonder where they got it wrong?

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
<script type="text/javascript">
    function getir(id) {
    alert(document.getElementById(id).Value);

    }
</script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="txt" runat="server"></asp:TextBox>

    </div>
    </form>
    <p>
        <input id="Button1" type="button" value="button" onmouseover="getir('<%= txt.ClientID %>')" /></p>
</body>
</html>

解决方案

You have not told about the error, but try:
alert(document.getElementById(id).value);

Value with small ''V'' in it.


Javascript is case sensitive languge..

alert(document.getElementById(id).value);



Try This one.


这篇关于如何添加getElementById(id)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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