开发者社区 问答 正文

id是动态的,请问jQuery怎么修改input标签的value值?在线等解答

<input type="button" id="${personID }" style="color: red;background-color: yellow;" onclick="toPowerSet(this.id);" value="${powerSet }"/>

在这个input标签中,怎么修改value的值

展开
收起
a123456678 2016-07-12 10:12:21 3542 分享 版权
1 条回答
写回答
取消 提交回答
  • $(document).on('click','button',function(){
    
    //改变val    
    
    $(this).val('xxxx');
    
    //获取id
    
    $(this).attr('id');
    
    });
    

    'button'处最好用一个class代替,比如给每个input 加上 changeVal之类的class就行了,然后用

    2019-07-17 19:54:41
    赞同 展开评论