jQuery删除当前节点元素
下面一段代码给大家介绍了jquery删除节点元素的方法,具体代码如下所示;
//state用来判断获取内容的状态,单击一次获取文本内容,第二次单击删除内容 var state = 0; function getfilecontent(btn){ //这边用来判断是否已经获取到文本内容,获取到则删除 if(state == 1){ var td = $(btn).parent().parent().next().children(); td.remove(); state = 0; return; } var filePath = document.getElementById("filepath").innerHTML.trim(); var tr = btn.parentNode.parentNode; var tds = tr.getElementsByTagName("td"); var fileName = tds[0].innerHTML.trim(); $.post("<%=basePath%>intelligentjournal/getfilecontent.do", { "filePath":filePath, "fileName":fileName },function(fileContent){ var file = fileContent; var ntr = document.createElement("tr"); ntr.innerHTML = '<td style="border:1px solid black" id = "td">' + file + '</td>'; var tr1 = document.getElementById(fileName); tr1.appendChild(ntr); },"JSON"); state = 1; }
相关推荐
zrtlin 2020-11-09
xuebingnan 2020-11-05
wikiwater 2020-10-27
heheeheh 2020-10-19
Crazyshark 2020-09-15
softwear 2020-08-21
ZGCdemo 2020-08-16
jczwilliam 2020-08-16
littleFatty 2020-08-16
idning 2020-08-03
jinxiutong 2020-07-26
lanzhusiyu 2020-07-19
Skyline 2020-07-04
xiaofanguan 2020-06-25
Aveiox 2020-06-23
dragonzht 2020-06-17