下面都是正确的:
但是 我之前的错误是 比如想取value值吧
可能这样搞: $(thisButton).value 得不到
然后想取前面一个元素 用 thisButton.prev()也得不到
因为 prev() val() remove() hide() append() 属于jquery的操作分别是便利 取值 文档操作等所以都要用
$(thisButton)
还有一个错误受下面黑体的那个删除函数影响 我错误的把下面小字正确的那个删除调用写成了
("#joinask").append(" <input type='button' value='删除' onclick='deletRow(function(){
deletRow( this);});'/>");
传进去的参数变成了
function(){
deletRow( this);}所以一直报错没有定义 当时比较二逼。正确的要么直接就是
$("#joinask").append(" <input type='button' value='删除' onclick='deletRow(this);'/>");简单易懂
要么模仿真的就是:onclick ='function (){deletRow(this);} ';
$.ajax({
url:'table/admintable.jsp',
type:'GET',
dataType:'html',
cache: false,
success: function(response){
$("#pagecontent").html(response);
$(".loading").hide();
$(".updateinfo").click(function(){
updateAdminInfo(this);
});
$("#newadminconfirm").click(function(){
addNewAdmin();
});
$(".deleteinfo").click(function(){
deleteAdmin(this);
});
}
});
function addRow(){
var i=0;
i++;
$("#joinask").append(" <br/><input type='text' class='text' id=i value='neirong' style='width:430px;'/> ");
$("#joinask").append(" <input type='button' value='删除' onclick='deletRow(this);'/>");
}
function deletRow(thisButton){
num = $(thisButton).val();
alert(num);
}
function deletRow(thisButton){
num = thisButton.value;
alert(num);
}
function deletRow(thisButton){
num = $(thisButton).prev().remove();
}
function deletRow(thisButton){
$(thisButton).prev().attr("value","lxy");
$(thisButton).prev().hide();
$(thisButton).attr("value","lxy");
$(thisButton).hide();
$(thisButton).prev().remove();
$(thisButton).remove();
}