javascript 代碼片段

1 select獲取改變之前的值
  1. var previous;
  2. $("select").focus(function () {
  3.     // Store the current value on focus, before it changes
  4.     previous = this.value;
  5. }).change(function() {
  6.     // Do something with the previous value after the change
  7.     alert(previous);
  8. });
2 javascript保留兩位小數
  1. parseFloat(num).toFixed(2);
  2. //or
  3. Math.round(num * 100) / 100
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章