getting the value of dynamically created textbox using jquery

前端 未结 6 946
悲&欢浪女
悲&欢浪女 2020-12-18 09:50

I\'m having a hard time with getting the value of my dynamically appended textboxes. I\'m using the $.each function to iterate all of the textboxes according to

6条回答
  •  孤城傲影
    2020-12-18 10:18

    You can just use the item parameter:

    $('#save_grade_button').click(function (){
         $('input[type=text]').each(function(i, item) {
             var grade =  $(item).val();
             alert(grade);
         });
     });
    

    OR with @Adil's answer combined:

    $('#save_grade_button').click(function (){
         $('[id^=student_grde_G]').each(function(i, item) {
             var grade =  $(item).val();
             alert(grade);
         });
     });
    

提交回复
热议问题