0
React TestUtils.simulateは、oninput関数も起動させます。しかし、いくつかの制限のために、私はそれを使用することができません。jQueryを使用してkeypressをシミュレートし、oninputを呼び出す
シミュレートし、それによって、oninput機能が起動するのjQueryを使用してkerypressを引き起こす方法はありますか?
React TestUtils.simulateは、oninput関数も起動させます。しかし、いくつかの制限のために、私はそれを使用することができません。jQueryを使用してkeypressをシミュレートし、oninputを呼び出す
シミュレートし、それによって、oninput機能が起動するのjQueryを使用してkerypressを引き起こす方法はありますか?
これはどういう意味ですか?
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form>
<fieldset>
<label for="target">Type Something:</label>
<input id="target" type="text">
</fieldset>
</form>
<button id="other">
Trigger the handler
</button>
<script src="/resources/events.js"></script>
<script>
var xTriggered = 0;
$("#target").keypress(function(event) {
if (event.which == 13) {
event.preventDefault();
}
xTriggered++;
var msg = "Handler for .keypress() called " + xTriggered + " time(s).";
console.log(msg, "html");
console.log(event);
});
$("#other").click(function() {
$("#target").keypress();
});
</script>
はい、トリガ方法が表示されます – Salketer