Html newly added in the id, js get less than id

 if(flag==0){
                var p = document.createElement("p");
                 var text_p = document.createTextNode("还没有账号0?");
                 p.setAttribute("class","p-rj");
                 p.setAttribute("id","prj");
                 p.appendChild(text_p);
                   var a = document.createElement("a");
                   var text_a = document.createTextNode("注册0");
                     a.setAttribute("href","javascript:void(0);");  
                     a.setAttribute("class","drop_col");
                     a.setAttribute("id","register");
                     a.setAttribute("onclick","rjSecond()");
                     a.appendChild(text_a);
                  p.appendChild(a);
                    $ ( "boss") appendChild ( p);.} // changed after the HTML content increases. Found that they could not get id, I set the onclick attribute bug finally solve
                flag = 1; 

.....

                       / * $ ( "Register") . Onclick = function () { before used this way, but no way to obtain value register id, do not know why the new increase in the HTML, the page has been formed, but again, click on the bindings when an event tag, id can not get to. * /
  Function rjSecond ()
      {var = document.getElementsByTagName Table ( "Table") [0];
        var form = table.parentNode;
        form.removeChild (Table)
        IF (! In Flag = 0) {
          var div = $ ( "Submit -div ");
         form.removeChild (div);
        ........
        

Guess you like

Origin www.cnblogs.com/hyjh/p/11258629.html