jquery 与 html 取值混淆

下面都是正确的:

但是 我之前的错误是 比如想取value值吧

可能这样搞: $(thisButton).value 得不到

然后想取前面一个元素 用  thisButton.prev()也得不到

因为 prev() val() remove() hide() append() 属于jquery的操作分别是便利 取值 文档操作等所以都要用

 $(thisButton)


还有一个错误受下面黑体的那个删除函数影响 我错误的把下面小字正确的那个删除调用写成了
("#joinask").append(" <input type='button'  value='删除'  οnclick='deletRow(function(){  

deletRow( this);});'/>");

传进去的参数变成了

function(){  

deletRow( this);}所以一直报错没有定义 当时比较二逼。正确的要么直接就是

    $("#joinask").append(" <input type='button'  value='删除'  οnclick='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='删除'  οnclick='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();
    }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值