Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
<input type="number" id="input">
</body>
</html>
 
// const props = Reflect.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value');
// Reflect.defineProperty(input, 'value', {
//     ...props,
//     set (v) {
//         let oldv = this.value;
//         props.set.call(this, v);
//         // 手动触发change事件
//         if (oldv !== v) {
//               this.dispatchEvent(new CustomEvent('change'));
//         }
//     }
// });
// input.addEventListener('change', () => {
//   document.body.append('变化啦~');
// });
// input.value = 'zhangxinxu';
console.log(Reflect.set(input, 'type', 'zhangxinxu'));
Output 300px

This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers