06011991 06011991 - 1 month ago 7
HTML Question

Alert is not working on tags input bootstrap using jquery

Jquery alert is not working for

tags input
bootstrap input field.
HTML:

<input type="text" name="cities" class="form-control newCity" data-role="tagsinput" />


Jquery:

$(document).on('keyup mouseup', ".newCity", function(e) {
e.preventDefault();
alert('hello');

});


I've tried with
keyup
,
mousedown
,
mouseup
,
mouseout
nothing is working.

JS Fiddle link : Here

Any Suggestions, Please!

Answer Source

Because you are not doing anything in input.

Your input is hidden and bootstrap adding another element in place of your input.

Inspect the input you can see this.

See the demo: fiddle

$(document).on('keyup', ".bootstrap-tagsinput", function(e) {
alert('hello');
    e.preventDefault();
});