select change 事件

群内问题一粒 select change 事件
如果用vue数据双向绑定更简单;
select change 事件

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=0">
    <title>select change</title>
     <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
  </head>
  <body>
    <script type="text/javascript">
    $(function(){
    var num=0;
    var len = 4;//显示的长度
    $("#slct").change(function () {
    num++;
    num = parseInt(num, 10);
    num = num.toString(); 
    while(num.length < len) {
    num = '0' + num;
    }
    console.log(num)
    $('#num').val(num)
    })
    })
    </script>
    <input type="text" id='num' value="0000" />
    <select id='slct'>
      <option value ="volvo">javascript</option>
      <option value ="saab">sass</option>
      <option value="opel">grunt</option>
      <option value="audi">vue</option>
      <option value="audi">jquery</option>
      <option value="audi">bootstrap</option>
    </select>
  </body>
</html>
来都来了,留个言吧🙂