js代码
<script> //Global: var survey = []; //Bidimensional array: [ [1,3], [2,4] ] //switcher function: $(".rb-tab").click(function(){ //Spot switcher: $(this).parent().find(".rb-tab").removeClass("rb-tab-active"); $(this).addClass("rb-tab-active"); }); //Save data: $(".trigger").click(function(){ //Empty array: survey = []; //Push data: for (i=1; i<=$(".rb").length; i++) { var rb = "rb" + i; var rbValue = parseInt($("#rb-"+i).find(".rb-tab-active").attr("data-value")); //Bidimensional array push: survey.push([i, rbValue]); //Bidimensional array: [ [1,3], [2,4] ] }; //Debug: debug(); }); //Debug: function debug(){ var debug = ""; for (i=0; i<survey.length; i++) { debug += "No " + survey[i][0] + " = " + survey[i][1] + "\n"; }; alert(debug); }; </script>
在线预览
资源均来自第三方,谨慎下载,前往第三方网站下载