zoukankan      html  css  js  c++  java
  • ASP.NET#使用母版时,如果要使用js中的getElementById()方法取得某个内容页的元素时要注意的问题

    当使用母版,要使用js中的getElementById()方法取得某个内容页的元素时,所选取的id并不是母版中内容页的id,而是在设计内容页时设定的id
    例子:
    母版页:

    ......
    <head runat="server">
    <title>无标题页</title>
    <link href="../css/default.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" language="javascript">
    function fff() {
    var text = document.getElementById("huifu1");//要取得内容页的元素
    if (text != null) {
    text.focus();
    }
    }
    </script>
    </head>
    <body style=" color:Black">
    <form id="form1" runat="server">
    <div id="outer">
    <div id="inner">
    <div>
    <uc1:liuyan ID="liuyan1" runat="server" />
    </div>
    <br /> <br />
    <uc2:huifu ID="huifu1" runat="server" />//要取得的元素应该是在该内容页面中
    </div>
    </div>
    </form>
    </body>
    </html>

    内容页:

    <table style="650px; height:300px" id="huifu1">
    ...
    </table>
  • 相关阅读:
    vuex详解
    es6 数组方法的扩展
    es6class语法和继承
    变量的解构赋值
    es6变量let
    前端模块化
    webpack基础
    react中的redux(入门)
    react-router-dom中的BrowserRouter和HashRouter和link与Navlink
    react-router-dom
  • 原文地址:https://www.cnblogs.com/KeenLeung/p/3295794.html
Copyright © 2011-2022 走看看