HTML input 标签失去焦点后触发JS

291 阅读1分钟

HTML input 标签失去焦点后触发JS

失去焦点时触发操作
<input type="text" name="" id="addFocus" onblur="alterMessage(this)">
<script>
function alterMessage(e) {
    console.log(e.value);
}
</script>
jQuery添加焦点
$('input#addFocus').focus();