如何在javascript中访问#document / sub文档中的元素

时间:2017-06-07 17:37:02

标签: javascript dom

运行createLogin()

后,无法访问#document中的元素

到目前为止我尝试过的事情

1:document.getElementtById(“signIn-container”);
2:document.getElementById(“object #document div.signIn-container”);
3:document.getElementById(“#document.signIn-container”);
4:document.querySelectorAll(“signIn-container”);返回空数组

function createLogin(){
  var x = document.getElementById("route-view");
  x.innerHTML= '<object type="text/html" data="./resources/views/logIn.html" ></object>';
};
 <html>
 <head>...</head>
 <body>
     <header>
     
            </header>
            
 <div id="top-app-name-container">...</div>
 <div id="nav">...</div>
 <!-- routing view --> == $0
   <object type="text/html" data="./resources/views/login.html">
   #document
   <html>
    <head>...</head>
    <body>
    <div id="signIn-container">
     <div class="username">..</div>
     <div class="password">..</div>
     </div>
     </body>
     </html>
     </object>

0 个答案:

没有答案