Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JavaScript从dom中删除child输入_Javascript_Materialize_Removechild - Fatal编程技术网

JavaScript从dom中删除child输入

JavaScript从dom中删除child输入,javascript,materialize,removechild,Javascript,Materialize,Removechild,我正试图删除发布到DOM上的表单输入,但removeChild代码不起作用,当检查控制台时,我将收到一个错误,即:materialize.min.js:6 Uncaught TypeError:无法读取HTMLBodyElement.value(materialize.min.js:6)处null的属性“m_Modal” /------------模型具体化框架---------------- document.addEventListener('DOMContentLoaded',()=>{

我正试图删除发布到DOM上的表单输入,但removeChild代码不起作用,当检查控制台时,我将收到一个错误,即:
materialize.min.js:6 Uncaught TypeError:无法读取HTMLBodyElement.value(materialize.min.js:6)处null的属性“m_Modal”

/------------模型具体化框架----------------
document.addEventListener('DOMContentLoaded',()=>{
var elems=document.querySelectorAll('.modal');
var实例=M.Modal.init(elems);
});
//删除练习
const delExerciseBtn=document.querySelector('.del exercisebtn');
delExerciseBtn.addEventListener('单击',(e)=>{
如果(e.target.className=='delete'){
常量h6=e.target.parentElement;
h6.removeChild(e.target);
}
});
//将用户的添加到Dom。
const addExerciseDom=document.querySelector('.exercisedom');
const exerciseForm=document.querySelector('.exerciseForm');
exerciseForm.addEventListener('submit',(e)=>{
e、 预防默认值();
//获取输入值
常量值=exerciseForm.querySelector('input[type=“text”]”)。值;
//创建元素
const h6=document.createElement('h6');
//添加内容
h6.textContent=值;
//附加到Dom
addExerciseDom.appendChild(h6);

});您可以这样做

/------------模型具体化框架----------------
document.addEventListener('DOMContentLoaded',()=>{
var elems=document.querySelectorAll('.modal');
var实例=M.Modal.init(elems);
});
//删除练习
const delExerciseBtn=document.querySelector('.del exercisebtn');
delExerciseBtn.addEventListener('单击',(e)=>{
const h6=document.getElementsByTagName('h6')[0];
h6.移除();
});
//将用户的添加到Dom。
const addExerciseDom=document.querySelector('.exercisedom');
const exerciseForm=document.querySelector('.exerciseForm');
const disabledExersiceBtn=document.querySelector('.disabled exerciebtn');
exerciseForm.addEventListener('submit',(e)=>{
e、 预防默认值();
//获取输入值
常量值=exerciseForm.querySelector('input[type=“text”]”)。值;
//创建元素
const h6=document.createElement('h6');
//添加内容
h6.textContent=值;
//附加到Dom
addExerciseDom.appendChild(h6);
//禁用Btn
disabledExersiceBtn.setAttribute('disabled','disabled');
});用于h6的多个值
最好为每个新h6添加id
检查体重和运动

//实现自动完成的初始化,练习。
document.addEventListener('DOMContentLoaded',()=>{
var elems=document.querySelectorAll('.autocomplete');
var instances=M.Autocomplete.init(elems{
数据:{
“横向下拉”:空,
“横向下降”:空,
},
限额:2,
最小长度:1,
});
});
//具体化框选择、设置和重复的初始化。
document.addEventListener('DOMContentLoaded',()=>{
var elems=document.querySelectorAll('select');
var实例=M.FormSelect.init(elems);
});
//具体化权重CharacterCount的初始化
document.addEventListener('DOMContentLoaded',()=>{
var textNeedCount=document.querySelectorAll('.weightCounter');
M.CharacterCounter.init(textNeedCount);
});
//需要在不提交的情况下限制输入框中的数字
//-------模型具体化框架----------------
document.addEventListener('DOMContentLoaded',function(){
var elems=document.querySelectorAll('.modal');
var实例=M.Modal.init(elems);
});
//------将表单的输入添加到主页----------------
//-------------练习------------
//从Dom中删除练习
const delExerciseBtn=document.querySelector('.del exercisebtn');
delExerciseBtn.addEventListener('单击',(e)=>{
//删除表单输入
const h6_e=document.getElementById('h6_exercise');
h6_e.移除();
//删除禁用Btn
disabledExersiceBtn.removeAttribute(“已禁用”);
});
//将用户的练习添加到Dom中。
const addExerciseDom=document.querySelector('.exercisedom');
const exerciseForm=document.querySelector('.exerciseForm');
const disabledExersiceBtn=document.querySelector('.disabled exerciebtn');
exerciseForm.addEventListener('submit',(e)=>{
e、 预防默认值();
//获取输入值
常量值=exerciseForm.querySelector('input[type=“text”]”)。值;
//创建元素
//const h6=document.createElement('h6');
//锻炼
const h6_exercise=document.createElement('h6');
//添加内容
h6_exercise.textContent=值;
//添加id
设置属性(“id”,“h6_练习”);
//附加到Dom
附录练习。附录儿童(h6_练习);
//禁用Btn
disabledExersiceBtn.setAttribute('disabled','disabled');
});
//---------------------重量----------------------
//从Dom中删除练习
const delweightbn=document.querySelector('.delWeightBtn');
delWeightBtn.addEventListener('单击',(e)=>{
//删除表单输入
设h6_r=document.getElementById('h6_-weight');
h6_r.移除();
});
//将用户的权重添加到Dom中。
const addWeightDom=document.querySelector('.weightdom');
const-weightForm=document.querySelector(“.weightForm”);
weightForm.addEventListener('submit',(e)=>{
e、 预防默认值();
if(document.getElementById('h6_-weight'))
{
设h6_r=document.getElementById('h6_-weight');
h6_r.移除();
}
//获取输入值
常量值=weightForm.querySelector('input[type=“number”]”)。值;
const value1=weightForm.querySelector('input[type=“text”]”)。值;
//console.log(值,value1);
//创建元素
常量h6_weight=document.createElement('h6');
setAttribute('id','h6_-weight')
//h6.classList.add(“中心”);//不工作
//添加内容
h6_weight.textContent=value+“”+value1;
//附加到Dom
addWeightDom.appendChild(h6_重量);
});
// -