How to convert value to string you have three ways Converting a value to string in JavaScript String(value) “” + value value.toString() value.toString is the worst. It doesn’t always work. So don’t use it. I personally use String(value) or “” + value How to use this (hard binding in javascript) this is a binding…
Category: JavaScript
IOS position fixed doesn’t work
On the IOS devices position fixed doesn’t work. I had a task where needs to add the button above the appeared keyboard. The button stuck to the bottom, so I did such a code show »
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
<script> console.log('1hello world'); window.addEventListener('resize', () => { console.log('window') }) let flag = null var userAgent = navigator.userAgent || navigator.vendor || window.opera; const f = () => { console.log('userAgent = ', userAgent); if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream && window.innerWidth < 800 && !flag) { console.log('once'); flag = true document.getElementById('ServiceFilter_1163_MIN').addEventListener('focus', () => {console.log('focus1') setTimeout(() => { document.querySelector('.bx_filter_button_box').style.bottom="calc(50% + 10px)" document.querySelector('.bx_filter_button_box').style.display="block" },1000) }) document.getElementById('ServiceFilter_1164_MIN').addEventListener('focus', () => {console.log('focus1') setTimeout(() => { document.querySelector('.bx_filter_button_box').style.bottom="calc(50% + 10px)" document.querySelector('.bx_filter_button_box').style.display="block" },1000) }) document.getElementById('ServiceFilter_1163_MAX').addEventListener('focus', () => {console.log('focus1') setTimeout(() => { document.querySelector('.bx_filter_button_box').style.bottom="calc(50% + 10px)" document.querySelector('.bx_filter_button_box').style.display="block" },1000) }) document.getElementById('ServiceFilter_1164_MAX').addEventListener('focus', () => {console.log('focus2') setTimeout(() => { document.querySelector('.bx_filter_button_box').style.bottom="calc(50% + 10px)" document.querySelector('.bx_filter_button_box').style.display="block" },1000) }) document.getElementById('ServiceFilter_1163_MAX').addEventListener('blur', () => {console.log('focus1') setTimeout(() => { document.querySelector('.bx_filter_button_box').style.bottom="0px" },0) }) document.getElementById('ServiceFilter_1164_MAX').addEventListener('blur', () => {console.log('focus2') setTimeout(() => { document.querySelector('.bx_filter_button_box').style.bottom="0px" },0) }) document.getElementById('ServiceFilter_1163_MIN').addEventListener('blur', () => {console.log('focus1') setTimeout(() => { document.querySelector('.bx_filter_button_box').style.bottom="0px" },0) }) document.getElementById('ServiceFilter_1164_MIN').addEventListener('blur', () => {console.log('focus2') setTimeout(() => { document.querySelector('.bx_filter_button_box').style.bottom="0px" },0) }) } } setTimeout(() => { console.log('here we are'); f() },0) window.addEventListener("resize", function () { // console.log(window.innerWidth); // console.log('flag = ', flag); console.log('userAgent = ', userAgent); // iOS detection from: http://stackoverflow.com/a/9039885/177"20 f() }); </script> |
And after clicking on the input field the button was jumping in any places. It wasn’t fixed. Do…
How to use regular expression in javascript
JavaScript has e main functions to work with the regular expression namely replace, match, exec Regular expression flags g – global search i – case-insensitive search m – multiline search s – allows . to match newline characters u – “unicode”; treat a pattern as a sequence of unicode points y – Perform a “sticky”…
JavaScript tasks that will master skill
Doing these tasks on your own you’ll get very quickly a JavaScript master level These tasks will make a real practical skill. As know the repetition is a mother of the teaching. The usage instruction Select the task that you more like and start study code. Afterward when you know how the code works. Do the…