This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| > location.search返回的是问号之后的URL,包括问号,location.hash返回的是URL中的片段标识符,包括'#' | |
| function urlArgs(){ | |
| var args = {}; | |
| var query = location.search.substring(1); | |
| var pairs = query.split('&'); | |
| for(var i=0; i<pairs.length; i++){ | |
| var pos = pairs[i].indexOf('='); | |
| if(pos == -1) continue; | |
| var name = pairs[i].substring(0, pos); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div id="rosa"> | |
| <button>fullScreen!</button> | |
| <button>exit!</button> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var ele = document.getElementById("content"); | |
| function fullScreen() { | |
| if (!document.mozFullScreen && !document.webkitFullScreen) { | |
| if (ele.mozRequestFullScreen) { | |
| ele.mozRequestFullScreen(); | |
| } else { | |
| ele.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*! | |
| * isVis - v0.5.6 Sep 2012 - Page Visibility API Polyfill | |
| * Copyright (c) 2011 Addy Osmani | |
| * Dual licensed under the MIT and GPL licenses. | |
| */ | |
| /* | |
| * https://gist.github.com/3793323 | |
| * Firefox support added based on https://developer.mozilla.org/en-US/docs/DOM/Using_the_Page_Visibility_API | |
| * <a href="/juanmhidalgo">@juanmhidalgo</a> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getCountofG(array){//Implemetion } | |
| var myArray=[123,2121,3219,79881]; | |
| //myArray turned into ["74","75D","B26","G46F"]; | |
| getCountofG(myArray); //return 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <ul> | |
| <li id="zero"></li> | |
| <li id="one"></li> | |
| <li id="two"></li> | |
| </ul> | |
| <script> | |
| getIndexParent(document.getElementById('zero')); //return 0 | |
| getIndexParent(document.getElementById('one')); //return 1 | |
| </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 这应该算简单的算法题,我没深入学习过算法,所以只有用第一反应得到的方法来解答啦 | |
| 思路:写一个判断数字是否是素数的函数,然后在循环中调用它,将所得的结果push到数组中,解法如下: | |
| var prime=[]; | |
| for(var i=0;i<10000;i++){ | |
| isPrime(i)?prime.push(i):null; | |
| } | |
| function isPrime(num){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 这道题有两种思路: | |
| 1.第一种是获得所有的LI元素,然后从中取出含有test类的元素设置背景为黄色: | |
| //通用做法 | |
| var liArray=document.getElementsByTagName("li"); | |
| for(var i=0,l=liArray.length;i<l;i++){ | |
| var pattern=/\btest\b/, | |
| self=liArray[i]; | |
| //考正则的话考点就在这里,考察对正则的几个常用方法的掌握,还可以使用: | |
| //liArray[i].className.search!=-1?self.style.background="yellow":null; | |
| //pattern.test(liArray[i].className)?self.style.background="yellow":null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function loadModule(id) { | |
| var codeElement = document.getElementById(id), | |
| code = codeElement.innerHTML; | |
| eval(stripOutCommentBlock(code)); | |
| } | |
| function stripOutCommentBlock(str) { | |
| return str.replace(//*/, ).replace(/*//, ); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ###语法和属性 | |
| **作用于弹性盒的属性: | |
| - display: flex | inline-flex; | |
| - flex-derection: row(default) | row-reverse | column | column-reverse; | |
| - flex-wrap: nowrap(default) | wrap | wrap-reverse; | |
| - flex-flow: <'flex-derection'> || <'flex-wrap'>; | |
| - justify-content: flex-start | flex-end | center | space-between | space-around; | |
| - align-items: flex-start | flex-end | center | baseline | stretch; |
NewerOlder