2016-05-12 115 views
1

有没有任何方法可以将一个字段添加到某个部分的不同部分的div标签中。在不同页面的div标签中添加一个字段

我有

<div id="autoUpdate" class="autoUpdate" style="margin-left: 100px; display: none;" > 
     <table> 
       <tr> 
        <td><bean:message key="password.label" /></td> 
        <td><html:password property="password" maxlength="100" /></td> 
       </tr> 
       <tr> 
        <td><bean:message key="re-type.password.label" /></td> 
        <td><html:password property="password" maxlength="100" /></td> 
      </tr> 

     </table> 
</div> 

现在我想添加一些领域在这个div在同个HTML文件中下一个div标签一个按钮移到的点击。

回答

1

HTML:

<div id="autoUpdate" class="autoUpdate" style="margin-left: 100px; display: none;" > 
     <table> 
       <tr> 
        <td><bean:message key="password.label" /></td> 
        <td><html:password property="password" maxlength="100" /></td> 
       </tr> 
       <tr> 
        <td><bean:message key="re-type.password.label" /></td> 
        <td><html:password property="password" maxlength="100" /></td> 
      </tr> 

     </table> 
</div> 
<div onClick="addField('autoUpdate')">Add Field</div> 

的Javascript

function addField(field_id){ 
    var div = document.getElementById(field_id); 
    div.innerHTML = div.innerHTML + 'More content'; 
} 
相关问题