<script src="http://libs.baidu.com/jquery/1.8.3/jquery.min.js"></script>//在线链接<script type="text/javascript">$(document).ready(function(){
$('#get_pwd').click(function(){
var str ='mnbvcxzasdfghj0123klpoiuytrewq678MNBVCXZLKJH45GFDSAPOIUYT9REWQ';//字符串 var len = str.length;//查询字符串长度 var num=8;//生成字符串长度var code ='';for(var i =0; i < num; i++){
var rand = Math.ceil(Math.random()*len -1);//console.log(rand)
code+= str[rand];}$('#user_pws').val(code);//写入指定 input 框});})</script>