Search

8/30/2012

jquery trigger event

jquery trigger event - trigger event 的 event handler 第一個參數是一個虛擬的 event object


  function handleRangeChange(e, index) {
    if (e.hasOwnProperty('isTrigger')) {
      console.log ('from trigger event', arguments);
      $('#range').val(index)
    }
    else {
      console.log ('from native event', arguments);
      index = e.currentTarget.value
    }
  }

  $range = $('#range');
  $range.on('change', handleRangeChange);
  $('#changer').on('click', function( ) {
    $range.trigger('change', 5);
  });

沒有留言: