make it more easy after http://www.cnblogs.com/juandx/p/4058399.html 1 if you want the selected is what you choose after you submit the form use javascripts, then you should do this selected: params[:option] in options_for_select(); 2 if you want
<script> var a; // 变量提升 js中的作用域只有在函数中 {} 才称为作用域 if/for循环都不是 都会产生变量提升 console.log(a); { a = 2; console.log(a) } console.log(a) var arr = []; for (let i = 0;i<10;i++){ arr[i] = function () { console.log(i); } } arr[3](); //选项卡 var name = 'alex'; va