廢話不多說,直接上代碼。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>監聽input</title>
<script type="text/javascript" src="js/jquery-3.1.1.min.js"></script>
</head>
<body>
金額:<input type="text" id='othre'/>
<hr />
<div id='sxf'>手續費: <span></span></div>
<script type="text/javascript">
$(function(){
$("#othre").bind('input propertychange',function(){
$("#sxf span").text($(this).val()*0.006);
});
});
</script>
</body>
</html>