码迷,mamicode.com
首页 > 编程语言 > 详细

JavaScript通过id获取不到元素是什么原因阿?

时间:2016-12-18 20:44:09      阅读:183      评论:0      收藏:0      [点我收藏+]

标签:dex   没有   text   .text   keyword   ace   ntb   button   java   

s代码

JavaScript code
 
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function show_more_mess()
{
    $("#background_div").css("width","100%");//获取这个div的时候是没有问题的
    $("#background_div").css("height","100%");
    $("#background_div").css("position","absolute");
    $("#background_div").css("left","0");
    $("#background_div").css("top","0");
    $("#background_div").css("display","block");
    alert(document.getElementById("more_mess").innerHTML);//这边是作测试用的,报错显示获取不到这个元素
}
 
function show_div()
{
    $("#more_mess").css("display","block");//这边没有象没有执行一样
     
}



asp.net前台代码

C# code
 
?
1
2
3
4
5
6
7
<div id="background_div" runat="server" style="position:absolute; display:none; background:#999999; filter:Alpha(opacity=50)">
        </div>
        <div id="more_mess" runat="server" style="position:absolute;width:100px; height:100px; background:red; display:none; z-index:10">
            <div>账户:<asp:TextBox ID="TextBox_show_username" runat="server"></asp:TextBox></div>
            <div>密码:<asp:TextBox ID="TextBox_show_pwd" runat="server"></asp:TextBox></div>
             
        </div>



asp.net后台代码

C# code
 
?
1
2
3
4
5
6
7
8
9
10
11
12
background_div.InnerHtml = "<script>show_more_mess();";
        try
        {
            TextBox_show_pwd.Text = "a";
            TextBox_show_username.Text = "b";
            background_div.InnerHtml = "<script>show_div();</script>";
            //后台是可以获取到more_mess这个div的
 
        }
        catch (Exception ee)
        {
        }



  感觉很奇怪  希望高手能帮我看一下问题出在什么地方

JavaScript通过id获取不到元素是什么原因阿?

标签:dex   没有   text   .text   keyword   ace   ntb   button   java   

原文地址:http://www.cnblogs.com/icelab/p/6195392.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!