简体   繁体   中英

How to update a particular input field among dynamically created input fields in JavaScript, ajax from PHP response?

I want to update a particular input field from ajax response where the ajax would do query from that selected field and update the field.

<input class = "someclass" id="id1"></input>
<input class = "someclass" id="id2"></input>
<input class = "someclass" id="id3"></input>
<input class = "someclass" id="id4"></input>
.

Script:

 i=0;
    $('.someclass').focus();
    $("#button").click(function(){ 
    $("#id"+i).val("abc"); 
    });
    i++;

Any suggestion would be highly appreciated.

This will work for you,

 $("#button").click(function(){ 
    $(".someclass").val("abc"); 
    });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM