I have this jquery code:
$(document).ready(function(){
$(".main-input").on("input", function(){
$(".div-tags").show();
});
$(".div-tags a").on("click", function(){
var Optag = $(this).text() + "," + $(this).attr("data-id");
$(".main-input").focus();
$(".main-input").val(Optag);
return false;
});
$(".main-input").on('input', function(){
alert($(this).val());
});
});
What I need is that when I click on a link, text is placed in the input and immediately the event assigned to that input is executed.
Doing some research I came across the trigger function, which executes all the handlers and behaviors attached to the matching elements for the given event type.