Discuss / JavaScript / 练习

练习

Topic source

winner丶John

#1 Created at ... [Delete] [Delete and Lock User]

var dom = $('input,select');

            var arr = dom.map(function() {

                return this.value;

            }).get();

            function getGender(){

                        if(dom[3].checked){

                            return arr[3];

                        }else{return arr[4]}}

            json = {

                    name: arr[0],

                    email: arr[1],

                    password: arr[2],

                    gender: getGender(),

                    city: arr[5]

                }

            json=JSON.stringify(json);


  • 1

Reply