綁定事件的jQuery我有一個輸入:當MAXLENGTH被擊中
<input type="text" id="xpto" value="" maxlength="12" />
我想在maxlength
命中觸發事件。
我現在擁有的一切:
$("#xpto").keyup(function (e) {
if ($(this).val().length == parseInt($(this).attr("maxlength"))) {
//do stuff
}
});
這幾乎是完美的,因爲它沒有包括所有的可能性(即:用戶複製/粘貼值或選擇瀏覽器的建議值)。
我想在$.bind()
但我還沒有發現,包括我的方案的任何事件。任何幫助?
使用'$(document).on(「keyup change」,「#xpto」,function(){})' – Mohammad