Heim >Backend-Entwicklung >PHP-Tutorial > 检测旋钮所在行
检测按钮所在行
我想通过点击button触发change(this)事件,获取按钮所在行的id,然后调用changeTotext()方法,使所需要的单元格变换成文本框来进行修改数据,function change(obj){}方法不会写。
<br> nbsp;html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><br> <br> <br> <meta><br> <title>Insert title here</title><br> <script><br /> function showtd(num) { <br /> document.getElementById("bg"+num).style.display = "none";<br /> document.getElementById("show"+num).style.display = "block";<br /> }<br /> function hidetd(num) {<br /> document.getElementById("bg"+num).style.display = 'block';<br /> document.getElementById("show"+num).style.display = 'none';<br /> }<br /> <br /> function changeTotext() <br /> { <br /> var tdValue = obj.innerText; <br /> obj.innerText = ""; <br /> var txt = document.createElement("input"); <br /> txt.type = "text"; <br /> txt.value = tdValue; <br /> txt.id = "_text_000000000_"; <br /> txt.setAttribute("className","text"); <br /> obj.appendChild(txt); <br /> txt.select(); <br /> } <br /> <br /> function change(obj){<br /> <br /> <br /> }<br /> <br /> function mouseup(){ <br /> if (document.getElementById("sort_t") && event.srcElement.id != "sort_t") <br /> { <br /> var obj = document.getElementById("sort_t").parentElement; <br /> var txtValue = document.getElementById("sort_t").value; <br /> obj.innerText = txtValue; <br /> } <div class="clear"> </script>