Why does this code give me an error when the trigger
function executes? Please tell me the solution.
<input />
<input />
<div id='dd'></div>
x = $('input');
x.on("input", function() {
n = $(this).val();
if (x.eq(0).val() == n) {
$('#dd').html(n);
}
if (x.eq(1).val() == n) {
x.eq(0).val(n);
x.eq(0).trigger("input");
}
});
This jQuery code gives me an error in the browser console, but I don't know why.
jquery-3.4.1.min.js:2 Uncaught RangeError: Maximum call stack size exceeded
at String.replace ()
at Function.htmlPrefilter (jquery-3.4.1.min.js:2)
at k.fn.init. (jquery-3.4.1.min.js:2)
at _ (jquery-3.4.1.min.js:2)
at k.fn.init.html (jquery-3.4.1.min.js:2)
at HTMLInputElement. (userscript.js:5)
at HTMLInputElement.dispatch (jquery-3.4.1.min.js:2)
at HTMLInputElement.v.handle (jquery-3.4.1.min.js:2)
at Object.trigger (jquery-3.4.1.min.js:2)
at HTMLInputElement. (jquery-3.4.1.min.js:2)