This file contains 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 array = ["lily", "tom", "lucy"]; | |
var ele1 = "lily"; | |
var ele2 = "lucy"; | |
var ele3 = "jack"; | |
array.indexOf(ele1); // return 0 | |
array.indexOf(ele2); // return 2 | |
array.indexOf(ele3); //return -1; NOTE: element is not in the array if return -1 |
This file contains 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>item1</li> | |
<li class="active">item2</li> | |
<li>item3</li> | |
</ul> | |
<script> | |
$(ul).find(".active").index(); //return 1 | |
</script> |
This file contains 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
<style> | |
img{ | |
border-radius:10px; | |
} | |
</style> | |
<img src="xx.jpg"> |
This file contains 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
//查找同级元素 | |
$("#id").next(); // 下一个同级元素 | |
$("#id").prev(); // 前一个 | |
$("#id").nextAll("div"); // 所有该元素之后的同级div元素 | |
$("#id").prevAll("div"); | |
$("#id").prevAll("div").andSelf(); //所有该元素之前的同级div元素及该元素本身 |
This file contains 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
<style> | |
div{ | |
height:100px; | |
width:100px; /*宽高必须相等*/ | |
overflow:hidden; /*隐藏超出div的部分*/ | |
border-radius:50%;/*圆角为宽高的50%*/ | |
} | |
</style> | |
<div> |
This file contains 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
$("#ele").children().length>0; // if has children return true |
This file contains 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> | |
<p>123</p> | |
<p>321</p> | |
<p>456</p> | |
<p>789</p> | |
</div> | |
<script> | |
$("div p:first-child") //return <p>123</p> | |
</script> |
This file contains 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
{{#each data}} | |
<div>{{@index}}</div> <!-- start from 0--> | |
<div>{{this}}</div> <!-- "aa"--> | |
{{/each}} | |
<script> | |
var data = ["aa","bb"] | |
</script> |
This file contains 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
language: node_js | |
node_js: | |
- '4.0' | |
branches: | |
only: | |
- master | |
before_install: | |
- openssl aes-256-cbc -K $encrypted_e011a6d7eebf_key -iv $encrypted_e011a6d7eebf_iv -in .travis/id_rsa.enc -out ~/.ssh/id_rsa -d | |
- chmod 600 ~/.ssh/id_rsa | |
- eval $(ssh-agent) |
This file contains 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 isEmpty(obj) { | |
for (var prop in obj) { | |
if (obj.hasOwnProperty(prop)) { | |
return false; | |
} | |
} | |
return true; | |
} |
OlderNewer