What is the reason for JavaScript not getting the element by id?

Source: Internet
Author: User

Tag: Dex has no text. text keyword ace NTB button java

S code

JavaScript Code?
12345678910111213141516 functionshow_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);//这边是作测试用的,报错显示获取不到这个元素}functionshow_div(){    $("#more_mess").css("display","block");//这边没有象没有执行一样     }



asp. Net foreground code

C # code?
1234567 <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 Backend Code

C # code?
123456789101112 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)        {        }



I think it's Weird. I hope the master can help me see where the problem is.

What is the reason for JavaScript not getting the element by id?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.