简体   繁体   中英

Jquery exclude one event from on

I want to do something like this

$('body').on('input !focus','.totalprice',function(){
   do something
}

actually I am clearing the value of input on focus so I want to exlude that case

Try with focus event

$('body').on('focus', 'input.totalprice', function(){
   $(this).val('');
});

I am not Sure you looking for blur event

$('body').on('blur', 'input.totalprice', function(){
   $(this).val('');
});
$('body').on(':not(click) change','#chkbox',function(){
   alert( event.type );
})
$('body').on(':not(focus) click keyup change','#chkbox1',function(){
   alert( event.type );
})

try this way

demo

To clear the input field on focus, use

$('input').on('focusin', function() {
    this.value = '';
});

There is nothing called 'input !focus'

Focus event must be called as below

<input class="focusInput" type="text" value="one" />
<script type="text/javascript">
    $(document).on('focus', '.focusInput', function() {
        console.log('Focus');
    });
</script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM