difference between trigger() and triggerHandler() - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:triggerHandler

Description

difference between trigger() and triggerHandler()

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("input").select(function(){
        $("input").after(" Text marked!");
    });//from   w  ww.j a v  a  2s  . com
    $("#btn1").click(function(){
        $("input").trigger("select");
    });
    $("#btn2").click(function(){
        $("input").triggerHandler("select");
    });
});
</script>
</head>
<body>



<p><input type="text" value="Hello World"></p>

<button id="btn1">trigger()</button>
<button id="btn2">triggerHandler()</button>

</body>
</html>

Related Tutorials