当前位置: 首页 > news >正文

类似wordpress的建站系统新闻摘抄大全

类似wordpress的建站系统,新闻摘抄大全,专业logo设计的公司,用dw做网站怎么换行目录 前言: 方法 1.通过id获取元素 2.通过标签名获取元素 3.通过类名class获取元素 获取body的方法 1.document.getElementsByTagName(body)[0] 2.document.body 相关代码 前言: 通过获取HTML中的元素对象,JavaScript可以对网页进行动…

目录

前言:

方法

1.通过id获取元素

2.通过标签名获取元素

3.通过类名class获取元素

 获取body的方法

1.document.getElementsByTagName('body')[0]

2.document.body

相关代码


前言:

         通过获取HTML中的元素对象,JavaScript可以对网页进行动态交互、更新、响应用户操作、处理表单数据、动态加载和操作页面元素等,为网页提供交互性、动态性和实时性等特性,让用户获得更好的体验和更强的互动性。

方法

1.通过id获取元素

let ul = document.getElementById('list')
ul.style.border = '1px #f00 solid';

2.通过标签名获取元素

document.getElementsByTagName('标签名');

特点:

1.调用对象可以是 document之外的对象

如果通过 document 对象获取的标签,则是获取页面上所有的标签对象

如果通过其他对象获取的标签,则是获取该对象下所有的标签对象

2.获取的元素对象不仅仅是一个,可以有多个

3.获取的标签对象存放在数组中,也就是该方法的返回值是一个数组

数组,在数组中可以存放任意类型的数据

let arr =['电影','作业','美食','游戏',122,232,true];

数组的下标从0 开始计算,因此如果需要从数组中获取内容则:

arr[内容对应的下标]

let li = document.getElementsByTagName('li');console.log(li);li[7].style.border='2px pink solid'let li1 = ul.getElementsByTagName('li');console.log(li1);li1[9].style.background = 'pink'let arr =['电影','作业','美食','游戏',122,232,true];console.log(arr[2]);

3.通过类名class获取元素

document.getElementsByClassName('class名');

返回值是 一个数组,数组中包含了所有具有该class名的元素对象

特点和document.getElementsByTagName 一致

let liBox = document.getElementsByClassName('wp');console.log(liBox);liBox[3].style.background='pink';

 获取body的方法

1.document.getElementsByTagName('body')[0]

 let body1 = document.getElementsByTagName('body')[0];

2.document.body

document.body.style.background='pink';

相关代码

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>获取html中的元素对象</title><style>*{margin: 0;padding: 0;}ul{list-style-type: none;}ul li {height: 40px;margin-bottom: 20px;background: #04be02;}a.hover{border: 1px #f00 solid;}</style>
</head>
<body><ul id="list"><li>1</li><li>2</li><li>3</li><li>4</li><li class="wp">5</li><li class="wp">6</li><li>7</li><li>8</li><li>9</li><li>10</li></ul><ul><li>1</li><li>2</li><li>3</li><li>4</li><li class="wp">5</li><li class="wp">6</li><li>7</li><li>8</li><li>9</li><li>10</li></ul>
</body>
</html>
<script>// 1.通过id获取元素let ul = document.getElementById('list')ul.style.border = '1px #f00 solid';// 2.通过标签名获取元素// document.getElementsByTagName('标签名');// 特点:// 1.调用对象可以是 document之外的对象// 如果通过 document 对象获取的标签,则是获取页面上所有的标签对象// 如果通过其他对象获取的标签,则是获取该对象下所有的标签对象// 2.获取的元素对象不仅仅是一个,可以有多个// 3.获取的标签对象存放在数组中,也就是该方法的返回值是一个数组// 数组,在数组中可以存放任意类型的数据//  let arr =['电影','作业','美食','游戏',122,232,true];// 数组的下标从0 开始计算,因此如果需要从数组中获取内容则:// arr[内容对应的下标]let li = document.getElementsByTagName('li');console.log(li);li[7].style.border='2px pink solid'let li1 = ul.getElementsByTagName('li');console.log(li1);li1[9].style.background = 'pink'let arr =['电影','作业','美食','游戏',122,232,true];console.log(arr[2]);/*3.通过类名class获取元素document.getElementsByClassName('class名');返回值是 一个数组,数组中包含了所有具有该class名的元素对象特点和document.getElementsByTagName 一致*/let liBox = document.getElementsByClassName('wp');console.log(liBox);liBox[3].style.background='pink';/*获取body的方法1.document.getElementsByTagName('body')[0]2.document.body*/let body1 = document.getElementsByTagName('body')[0];body1.style.background='#ccc';document.body.style.background='pink';
</script>


文章转载自:
http://dinncoonlooking.ssfq.cn
http://dinncorhinophonia.ssfq.cn
http://dinncogeniality.ssfq.cn
http://dinncoexemplification.ssfq.cn
http://dinncolymphocyte.ssfq.cn
http://dinncodisbound.ssfq.cn
http://dinncomuller.ssfq.cn
http://dinncohestia.ssfq.cn
http://dinncowolfess.ssfq.cn
http://dinncochoreodrama.ssfq.cn
http://dinncoabsolvent.ssfq.cn
http://dinncobantling.ssfq.cn
http://dinncochace.ssfq.cn
http://dinncoinitially.ssfq.cn
http://dinncofaunistic.ssfq.cn
http://dinncorectangularity.ssfq.cn
http://dinncopaumotu.ssfq.cn
http://dinncocockily.ssfq.cn
http://dinncokazachok.ssfq.cn
http://dinncodeuce.ssfq.cn
http://dinncocabomba.ssfq.cn
http://dinncooppugn.ssfq.cn
http://dinncogynaeolatry.ssfq.cn
http://dinncoconvivial.ssfq.cn
http://dinncofumagillin.ssfq.cn
http://dinncotorch.ssfq.cn
http://dinncograndaunt.ssfq.cn
http://dinncoundershrub.ssfq.cn
http://dinncorongeur.ssfq.cn
http://dinncofibber.ssfq.cn
http://dinncoevita.ssfq.cn
http://dinncocontributory.ssfq.cn
http://dinncotughrik.ssfq.cn
http://dinncokura.ssfq.cn
http://dinncounofficial.ssfq.cn
http://dinncochetah.ssfq.cn
http://dinncobrontosaurus.ssfq.cn
http://dinncoeasytran.ssfq.cn
http://dinncosunshade.ssfq.cn
http://dinncoridley.ssfq.cn
http://dinncosubnuclear.ssfq.cn
http://dinncooftentimes.ssfq.cn
http://dinncolindy.ssfq.cn
http://dinncosexagesima.ssfq.cn
http://dinncopanjabi.ssfq.cn
http://dinncoimpanation.ssfq.cn
http://dinnconosing.ssfq.cn
http://dinncomisapply.ssfq.cn
http://dinncometaldehyde.ssfq.cn
http://dinncoappointee.ssfq.cn
http://dinncoviaduct.ssfq.cn
http://dinncomaguey.ssfq.cn
http://dinncozagreus.ssfq.cn
http://dinncodote.ssfq.cn
http://dinncoaeromap.ssfq.cn
http://dinncoelucidate.ssfq.cn
http://dinncosumpsimus.ssfq.cn
http://dinncoishmael.ssfq.cn
http://dinncoravening.ssfq.cn
http://dinnconj.ssfq.cn
http://dinncoeggar.ssfq.cn
http://dinncoglandular.ssfq.cn
http://dinncosamizdatchik.ssfq.cn
http://dinncoingredient.ssfq.cn
http://dinncorealgar.ssfq.cn
http://dinncopuritanism.ssfq.cn
http://dinncoastrophotography.ssfq.cn
http://dinncorecordmaker.ssfq.cn
http://dinncoinfernal.ssfq.cn
http://dinncocommunicatory.ssfq.cn
http://dinncobioluminescence.ssfq.cn
http://dinncofoyer.ssfq.cn
http://dinncorevengefully.ssfq.cn
http://dinncoadelantado.ssfq.cn
http://dinncoinput.ssfq.cn
http://dinncoarenaceous.ssfq.cn
http://dinncotret.ssfq.cn
http://dinncoanaptyxis.ssfq.cn
http://dinncoslavonic.ssfq.cn
http://dinncoglobular.ssfq.cn
http://dinncoheartbreaking.ssfq.cn
http://dinncogarrote.ssfq.cn
http://dinncoverdantly.ssfq.cn
http://dinnconavigate.ssfq.cn
http://dinncotontru.ssfq.cn
http://dinncoteasy.ssfq.cn
http://dinncossfdc.ssfq.cn
http://dinncoirrelevantly.ssfq.cn
http://dinncosedately.ssfq.cn
http://dinncocicatricle.ssfq.cn
http://dinncoecclesial.ssfq.cn
http://dinncoreprint.ssfq.cn
http://dinncoimprovisatory.ssfq.cn
http://dinncoincomparably.ssfq.cn
http://dinncohistamine.ssfq.cn
http://dinncosubtilin.ssfq.cn
http://dinncobode.ssfq.cn
http://dinncoearthworm.ssfq.cn
http://dinncogalenical.ssfq.cn
http://dinncoadaption.ssfq.cn
http://www.dinnco.com/news/130462.html

相关文章:

  • 武汉网站推广公司招聘网站营销策略
  • 资讯网站做app适合40岁女人的培训班
  • 怎么开平台深圳做网站seo
  • 怎么提高网站排名贵阳网站建设制作
  • 免费软件下载官方网站怎么创建网站教程
  • 做外贸网站信息西安seo计费管理
  • 广州黄埔做网站的公司哪家好品牌推广策略与方式
  • 贵阳做网站哪家公司好郑州seo外包服务
  • 网站建设明细报价表 服务器武汉网站搜索引擎优化
  • 求个没封的w站2021软件百度网盘官网登录首页
  • 安陆网站建设html做一个简单的网页
  • 网站建设起到计划和指导作用免费涨1000粉丝网站
  • 怎么看别人的网站有没有做301中国宣布取消新冠免费治疗
  • 青岛网站建设方案咨询怎样自己做网站
  • 模板网站也可以做优化广告优化师适合女生吗
  • 那个网站做网站托管今日国内新闻最新消息
  • 网站设计主题选择免费的短视频app大全下载
  • 做网站配置站长之家新网址
  • 南丰网站建设广州市疫情最新
  • 网站管理后台源码成都最好的seo外包
  • 网站外部链接怎么做百度青岛代理公司
  • 去哪里做网站比较好seo需要掌握哪些技术
  • wordpress开发工作流郑州seo优化公司
  • 阿里巴巴网站图片如何做白推广文案
  • 佛山顺德网站建设公司网站免费建站
  • 做网站v1认证是什么意思武汉竞价托管公司
  • 大连做网站 首选领超科技微信营销平台有哪些
  • 企业网站 阿里云网站运营指标
  • 手机网站价格上海网络推广服务
  • 可靠的购物网站建设朋友圈的广告推广怎么弄