ul

遍历ul下的li,点击弹出li的索引

匿名 (未验证) 提交于 2019-12-02 23:49:02
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> </head> <body> <ul id='ul'> <li>点我啊</li> <li>点我啊</li> <li>点我啊</li> <li>点我啊</li> <li>点我啊</li> </ul> </body> <script> // 第一种 var ul = document.getElementById('ul') ul.addEventListener('click',function(e) { var lis = ul.getElementsByTagName('li') for (let i = 0; i < lis.length; i++ ) { if (e.target == lis[i]) { alert(i+1) } } }) // 第二种 // var lis = document.getElementsByTagName('li') //

ul内li的缩进

匿名 (未验证) 提交于 2019-12-02 23:49:02
当ul list-style-type:none时,不会有任何的前缀,但li不会向前缩进,因为ul元素默认有padding-left,将padding-left设为0后li就会向前缩进。

网页的标题样式

匿名 (未验证) 提交于 2019-12-02 23:47:01
1 <html> 2 <head> 3 <title>标题示例</title> 4 <meta charset="UTF-8"> 5 <style> 6 /*在全局上清除盒模型的margin和padding*/ 7 * { 8 margin: 0; 9 padding: 0; 10 box-sizing: padding-box; 11 } 12 body { 13 padding-top: 100px; 14 text-align: center; 15 } 16 /*清除ul li的前缀*/ 17 ul li { 18 list-style: none; 19 } 20 /*清除超链接的下划线*/ 21 a { 22 text-decoration: none; 23 } 24 /*给标题容器div设置CSS*/ 25 div.menuDiv { 26 position: relative; 27 /* menu header width and height */ 28 height: 30px; 29 width: 610px; 30 border: #aabbff solid 2px; 31 display: block; 32 margin: 0 auto; 33 } 34 div.menuDiv ul a { 35 line-height: 30px; 36 } 37

P3370 【模板】字符串哈希

此生再无相见时 提交于 2019-12-02 22:38:48
题目地址 注意点: map直接用[]访问即可. #include<cstdio> #include<iostream> #include<map> #define ul unsigned long long using namespace std; const int MAXN=4000; map<ul,bool> has_; ul base=101; ul hashs[MAXN]; ul tmp[MAXN]; ul getHash(string str){ ul hash_=0; for(int i=1;i<=str.length();i++){ hashs[i]=hashs[i-1]*base+str[i-1]; } hash_=hashs[str.length()]; return hash_; } int main(){ int n; scanf("%d",&n); int cnt=0; for(int i=1;i<=n;i++){ string tmp; cin>>tmp; ul nowHash=getHash(tmp); if(has_[nowHash])continue; has_[nowHash]=1; cnt++; } printf("%d\n",cnt); return 0; }    来源: https://www.cnblogs.com/zbsy-wwx/p

JQuery attr() ת

匿名 (未验证) 提交于 2019-12-02 21:53:52
在JS中设置节点的属性与属性值用到setAttribute(),获得节点的属性与属性值用到getAttribute(),而在jquery中,用一个attr()就可以全部搞定了,赞一个先 ^^ jquery中用attr()方法来获取和设置元素属性,attr是attribute(属性)的缩写,在jQuery DOM操作中会经常用到attr(),attr()有4个表达式。 attr( 属性名 //取得第一个匹配元素的属性值。通过这个方法可以方便地从第一个匹配元素中获取一个属性的值。如果元素没有相应属性,则返回 undefined ) 2. 属性名, 属性值 ) //为所有匹配的元素设置一个属性值。 attr( 属性名 , 函数值 为所有匹配的元素设置一个计算的属性值。不提供值,而是提供一个函数,由这个函数计算的值作为属性值。 4. attr(properties) // 给指定元素设置多个属性值,即: {属性名一: “属性值一” , 属性名二: “属性值二” , … … } class 'class' 'id' html代码结构: < p title ="你最喜欢的水果是。" > 你最喜欢的水果是? </ p > < ul > < li title ="苹果汁" > 苹果 </ li > < li title ="橘子汁" value ="123" > 橘子 </ li > < li

jQuery事件

匿名 (未验证) 提交于 2019-12-02 21:53:52
jQuery事件注册有两种方式:常规注册和on()方法注册 常规注册:eventName(callback) on()方法注册 on(eventName,callback) on()方法还支持事件委托和自定义事件 事件委托:on('eventName',"子元素选择器",callback) 注意:回调函数中的this为对应的原生dom元素 <body> <ul id="ul"> <li>li - 1</li> </ul> </body> <script> // 常规注册 $("#ul").click(function(){ //this 为原生的dom元素 console.log("click ul") }) // on()方法注册 $("#ul").on("click",function(){ console.log("click ul-- on") }) // 动态添加子元素 var $li = $("<li id='test'>li - 2</li>") $("#ul").append($li) // 通过事件委托为子元素添加事件监听 $("#ul").on("click","#test",function(){ console.log("click li-- on") }) // 注册自定义事件 $("#ul").on("removeFirstChild",function

jQuery使用(一):jQuery对象与选择器

匿名 (未验证) 提交于 2019-12-02 21:53:52
*/ /*--> */ /*--> */ /*--> */ /*--> */ 一、简单的一些介绍 1.jQuery是由普通的是由一些系列操作DOM节点的函数和一些其他的工具方法组成的js库。 2.为什么要使用jQuery库?   jQuery面向用户良好的设计在使用过程中彻底解放了记忆原生操作DOM的接口。    jQuery中包含了可重用的函数,用来辅助我们简化JavaScript开发。   jQuery在半数以上并没有复杂交互的网站中得以大量使用,因为他们需要的仅仅是一些兼容低级浏览器又有炫酷效果动画的页面。    jQuery改变了数百万人编写JavaScript的方式,当然部分人已经觉得时过境迁,组件化,工程化大行其道,但不要忘记jQuery对前端开发者的启蒙意义!且很多公司项目依然需要使用。 3.jQuery注意点:   jQuery知识辅助工具,不能完全替代js,二者并存的方式出现在项目中;    jQuery很庞杂,先学使用再学思想。   jQuery方法很多,按需学习,把常用的学透彻。    jQuery API使用时可以现查现用,不难理解。 4.引入jQuery库:cdn:http://www.jq22.com/cdn/#a2 5.jQuery官网:中文: https://www.jquery123.com/ 英文原版: https://jQuery.com/ 二

a标签-导航练习

匿名 (未验证) 提交于 2019-12-02 20:37:03
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <style> *{ margin: 0; padding: 0; } ul{ width: 810px; height: 50px; background-color:green; margin: 100px auto; list-style: none; } ul li{ float: left; width: 90px; height: 50px; text-align: center; line-height: 50px; margin-left: 10px; } ul li a{ text-decoration: none; display: inline-block; width: 90px; height: 50px; } ul li a:visited{ color:blue; } ul li a:hover{ color: white;

向右方向的二级菜单

匿名 (未验证) 提交于 2019-12-02 20:32:16
<!DOCTYPE html> <html xmlns = "http://www.w3.org/1999/xhtml" > <head> <meta http-equiv = "Content-Type" content = "text/html; charset=utf-8" /> <title> 制作二级菜单 </title> <style type = "text/css" > body { margin : 0 ; padding : 0 ; font - family : Verdana , Arial , Helvetica , sans - serif ; font - size : 12px ; line - height : 1.5 ; } #menu ul { margin : 0 ; padding : 0 ; list - style : none ; border : 1px solid #ccc; width : 100px ; } #menu ul li { background - color : #eee; height : 26px ; line - height : 26px ; border - bottom : 1px solid #ccc; } #menu ul li a { color : #000; text -

zblog常用到的几个标签介绍

匿名 (未验证) 提交于 2019-12-02 20:32:16
文章归档 <divclass="function"id="divArchives"> <h3><#ZC_MSG028#></h3> <ul> <#CACHE_INCLUDE_ARCHIVES#> </ul> </div> <divclass="function"id="divSearchPanel"> <h3><#ZC_MSG085#></h3> <ul> <li> <formmethod="post"action="<#ZC_BLOG_HOST#>cmd.asp?act=Search"> <inputtype="text"name="edtSearch"id="edtSearch"size="12"/> <inputtype="submit"value="<#ZC_MSG087#>"name="btnPost"id="btnPost"/> </form> </li> </ul> </div> 站点统计 <divclass="function"id="divStatistics"> <h3><#ZC_MSG029#></h3> <ul> <#CACHE_INCLUDE_STATISTICS#> </ul> </div> 网站收藏 <divclass="function"id="divFavorites"> <h3><#ZC_MSG030#></h3> <ul> <#CACHE