简体   繁体   中英

how to traverse for input & textarea tag in jQuery?

I want to get form elements values individually, to achieve this I have written the following code but It's not working.

$('#slider_btn_save').click(function(){
  console.log($('#frm_main_slider').find('input[name="*"]').val());
})

You should do it like this

let values = {};
$('#frm_main_slider').find('input[name="*"]').each(function() {
  values[$(this).attr("name")] = $(this).val()
})
console.log(values)

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