hangfeng
hangfeng
1. ```javascript var bankCode = '6222081812002934027'; console.log(bankCode.replace(/(\d{4})/g, '$1 ')); ``` 2. ```javascript // zxx: 不错,支持小数 var numberCode = '995702375'; console.log(numberCode.replace(/\B(?=(\d{3})+\b)/g, ',')); ``` 3. ```javascript function formatFileSize (filesize = 1023) {...
```js 1. let str1 = str.replace(/fill="([^"]+)"/g, function (match, $1) { return $1 === 'none' ? match : "" }) 2. let encodeData = window.btoa(str) 3. let encodeStr = str.replace(/["%{}]/g, encodeURIComponent)...
```javascript 1. let dialog = document.createElement('dialog') document.body.appendChild(dialog) ``` ```javascript 2. dialog.setAttribute('open', true) ``` ```javascript 3. let button = document.createElement('button') button.innerText = "close dialog" button.onclick = function() { dialog.removeAttribute('open') } dialog.appendChild(button)...
[demo](https://jsbin.com/naxusis/edit?html,css,output) ```css /* zxx: 只能给个基础分了 */ ul { padding: 0; display: flex; } li { list-style: none; margin-right: 16px; border: 1px solid #c5c9cc; border-radius: 3px; padding: 1px 0 2px; }...
[demo](https://jsbin.com/yehecakaqu/edit?html,css,output) ```css .pic { width: 120px; height: 160px; } // 第一小题 .tag { color: #fff; font-size: 14px; padding: 3px 3px; position: absolute; background: #cd0000; } // 第二小题 .tag-triangle { padding:...
```javascript //zxx: 3,4测试不通过,缩进扣分 // 第一题: function toCamelCase(str) { let reg = /\-(\w)/g return str.replace(reg, function ($0, $1) { return $1.toUpperCase() }) } console.log(toCamelCase("hello-world-day-day-up")); // 第二题: function toDashJoin(str) { let reg...
```js 1. let radioRequired = document.querySelectorAll('[type="radio"]:required') 2. let radioDisabled = document.querySelectorAll('[type="radio"]:disabled') 3. let radioChecked = document.querySelectorAll('[type="radio"]:checked') 4. document.getElementById('removeDisabled').onclick = function () { [...radioDisabled].map(item => item.removeAttribute('disabled')); document.querySelector('fieldset').removeAttribute('disabled'); }; 5. [...document.querySelectorAll('[type="radio"]:invalid')] .map(item...