小编gag*_*ggi的帖子

如果手动切换flipswitch,如何仅触发事件

我已经创建了这样的jQuery Mobile flipswitch

<select id="flip" data-role="flipswitch">
    <option value="animal">Lion</option>
    <option value="flower">Rose</option>
</select>
Run Code Online (Sandbox Code Playgroud)

我听听这个翻转开关的变化

$( document ).on( 'change', '#flip', function( e ) {
   console.log( 'changed' );
}
Run Code Online (Sandbox Code Playgroud)

但是如果我改变flipswitch的值,我不希望触发事件

$( '#flip' ).val( 'flower' ).flipswitch( 'refresh' );
Run Code Online (Sandbox Code Playgroud)

如何通过直接与其交互或设置值并刷新翻转开关来检查翻转开关是否已更改?

我在这个JSFiddle下创建了一个不需要的行为的例子.

javascript jquery event-handling jquery-mobile jquery-mobile-flipswitch

6
推荐指数
1
解决办法
7436
查看次数