通过jQuery获取多种input值

取值

1.type='radio'

获取一组radio被选中项的值:const sex = $("input[name='sex']:checked").val();

2.type='text'

获取用户在文本框输入的值:const age = $("input[name='age']").val();

注意:input标签中不能缺少value属性

posted @ 2022-10-31 12:48  w中中w  阅读(83)  评论(0)    收藏  举报