在开发元素被确认后,在开发元素下方保留一个单击按钮
Keeping a click button underneath a dev element after it is cereated
我设置了一个添加按钮,以便在单击页面时将另一个div 元素添加到页面上。创建div 后,我无法将按钮放在新的div 元素下方。按钮保持原位,单击时将在其下方添加新的div,如果再次单击按钮,按钮仍保留在同一位置并添加一个额外的div。任何帮助将不胜感激。
<fieldset id="college">
<legend id="namefields"><h2>College, University or Professional School</h2></legend>
<table width="834">
<tr>
<td width="439" height="61">
Name of School <input type="text"size="40" maxlength="50" name="college" id="college"/>
</td>
<td width="383">
Location <input type="text" name="location" size="40">
</td>
</tr>
</table>
<table width="834">
<tr>
<td width="272" height="54">
Start Date <input type="date" name="date" size="10"></td>
<td width="273" height="54">
End Date <input type="date" name="date" size="10"></td>
<td width="273" height="54">
Credit Hours <input type="text" name="creditHrs" size="10"></td>
</tr>
</table>
<table width="869">
<tr>
<td width="439" height="61">
Course of Study <input type="text"size="40" maxlength="50" name="college" id="college"/>
</td>
<td width="418">
<label for="degreeType" id="degreeType">Degree Earned (transcripts may be required)</label>
<select style="width: 310px;" id="degreeType" name="degreeType" tabindex="0">
<option value="select one">Select One</option>
<option value="associates">Associates</option>
<option value="bachelors">Bachelors</option>
<option value="certification">Certification</option>
<option value="masters">Masters</option>
<option value="doctorate">Doctorate</option>
<option value="inprogress"> In Progress</option>
<option value="0">Not Applicable</option>
</select>
</td>
</tr>
</table>
</fieldset>
<button id= "addSchool" onclick="addSchool()">Add another school</button>
<script>
var original = document.getElementById('college');
function addSchool()
{
var clone = original.cloneNode(true);
original.parentNode.appendChild(clone);
}
</script>
</fieldset>
</div>
没有jQuery你可以使用insert之前像这样
var original = document.getElementById('college');
var button = document.getElementById('addSchool');
function addSchool(){
var clone = original.cloneNode(true);
original.parentNode.insertBefore(clone,button);
}
http://jsfiddle.net/Zg2cE/
相关文章:
- CKEditor Widget-阻止编辑可编辑元素本身
- 如何设置html元素填充的动画
- 如何将HTML id分配给元素,以及如何将JavaScript应用于元素
- 正在从开发人员工具中的select元素打印选项列表
- 从开发环境切换到生产环境时,可以使用grunt切换HTML元素
- Fetch元素鼠标当前指向的Chrome开发工具已启用
- 无法访问在开发人员工具中显示但不在页面源中的元素
- 在开发元素被确认后,在开发元素下方保留一个单击按钮
- 进度条元素破坏Chrome渲染(除非开发工具打开)
- 无法使用 Chrome 开发工具检查元素
- 在测试/开发时打印出 HTML 元素值的最佳方法是什么?
- CasperJS找不到元素,即使我可以在开发人员工具中按CTRL-F它
- 如何在chrome开发工具中通过Jquery获取元素集的事件监听器
- 可以通过浏览器中的开发人员控制台将值附加到选择元素上吗?
- CSS显示一个元素的内容在chrome使用F12开发工具
- 移除和读取一个元素会将另一个元素向下推,在开发工具中切换浮动会将元素移回正确的位置
- 将xul元素附加到网页(Firefox插件开发)
- 在开发人员窗口中显示内联样式元素,但在查看源代码时不显示
- 如何检查某种类型的多少元素有一个页面与Chrome扩展开发
- 在开发工具下获取可用元素->资源→帧