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

找人做网站要多少钱微商软文范例

找人做网站要多少钱,微商软文范例,想学网络营销网站建设,江苏广宇建设集团有限公司网站获取元素 1、getElementById() 通过id属性获取一个元素节点对象 <div id"div1"></div> <script> var div1 document.getElementById(div1) </script> 2、 getElementsByTagName()可以根据标签名来获取一组元素节点对象 这个方法会给我们返…

获取元素

1、getElementById() 通过id属性获取一个元素节点对象

<div id="div1"></div>

 <script>

       var div1 = document.getElementById('div1')

 </script>

2、 getElementsByTagName()可以根据标签名来获取一组元素节点对象

这个方法会给我们返回一个类数组对象,所有查询到的元素都会封装到对象中

即使查询到的元素只有一个,也会封装到数组中返回

<div id="div1"></div>

 <div class="cls"></div>

<div></div>

<script>

        var divs = document.getElementsByTagName('div')

        console.log(divs);     //  [div#div1, div.cls, div, div]

</script>

3、getElementsByName() 通过name属性获取一组元素节点对象

<div id="div1" name='nme'></div>

<div class="cls" name='nme'></div>

<div name='nme'></div>

<script>

        var divs = document.getElementsByName('nme')

        console.log(divs);  //  [div#div1, div.cls, div]

</script>

4、 getElementsByClassName() 通过class属性获取一组元素节点对象 (不支持IE8及以下浏览器)

<div id="div1" class="cls"></div>

<div class="cls"></div>

<div class="cls"></div>

<script>

        var divs = document.getElementsByClassName('cls')

        console.log(divs);  // [div#div1.cls, div.cls, div.cls]

</script>

5、 document.querySelector()

-需要一个选择器的字符串作为参数,可以根据一个css选择器来查询一个元素节点对象

-该方法总会返回唯一的元素,如果满足条件的元素是多个,那么它只会返回第一个

-IE8以上的都适用

<div id="div1" class="cls"></div>

<div class="cls"></div>

<script>

        var divs = document.querySelector('.cls')

        console.log(divs);  // <div id="div1" class="cls"></div>

</script>

<div id="div1" class="cls">

        <p></p>

</div>

<script>

        var p = document.querySelector('.cls p')

        console.log(p);  // <p></p>

.</script>

6、document.querySelectorAll()

-该方法和qureySelector()用法类似,

    不同的是它将会将符合条件的元素封装到一个数组中返回

    -即使符 合条件的元素只有一个,它也会返回数组

<div id="div1" class="cls"></div>

<div class="cls"></div>

<div class="cls"></div>

<script>

        var divs = document.querySelectorAll('.cls')

        console.log(divs);  // [div#div1.cls, div.cls, div.cls]

</script>

7、获取body标签

1、document.getElementsByTagName("body")[0]

2、document.body

8、获取html标签

document.documentElement

9、获取页面中的所有元素

1、document.all

2、document.getElementsByTagName("*")

操作元素

操作内容

element.innerText    从起始位置到终止位置的内容,但它去除html标签,同时空格和换行也会去掉

element.innerHTML   起始位置到终止位置的全部内容,包括HTML标签,同时保留空格和换

 <div class="box">

        <p> 内容 </p>

</div>

<script>

        var box = document.querySelector('.box')

        console.log(box.innerHTML);  //  <p> 内容 </p>

        console.log(box.innerText);  //  内容

</script>

操作属性

操作标签自带的属性

比如:src herf  value  chexked  disabled  title

<img src="./img1.png" alt="">

<input type="text">

<script>

        var img = document.querySelector('img')

        var ipt = document.querySelector('input')

        img.src = './img2.png'

        ipt.value = '直接赋值value'

</script>

操作元素样式

我们可以通过 JS 修改元素的大小、颜色、位置等样式。

1、修改行内样式操作

<img src="./img1.png" alt="">

<p>iedhfiuse</p>

<script>

        var img = document.querySelector('img')

        var p = document.querySelector('p')

        img.style.height = '100px'

        p.style.fontSize = '20px'

</script>

这种写法是通过js把样式写在行内

2、修改类名样式操作

<h1 class="title"></h1>

<p class="cont">iedhfiuse</p>

<script>

        var ttle = document.querySelector('.title')

        var cont = document.querySelector('.cont')

        ttle.className = 'title'

        cont.className = 'content'

</script>

这种方法需要提前在css中写好类名样式比如(title,content),然后通过js操作直接把类名换成写好的类名

注意:

JS里面的样式采取驼峰命名法,比如 fontSize ,backgroundColor
JS 修改 style 样式操作 ,产生的是行内样式,CSS权重比较高
如果样式修改较多,可以采取操作类名方式更改元素样式
class 因为是个保留字,因此使用className来操作元素类名属性
className 会直接更改元素的类名,会覆盖原先的类名

操作自定义属性

获取自定义的属性

element.getAttribute('属性');

<h1 class="title" index="'1"></h1>

<script>

        var ttle = document.querySelector('.title')

        console.log(ttle.getAttribute('index'));  //  1

</script>

设置自定义的属性

element.setAttribute('属性','值');

<h1 class="title"></h1>

<p class="cont">iedhfiuse</p>

<script>

        var ttle = document.querySelector('.title')

        var cont = document.querySelector('.cont')

        ttle.setAttribute('index', 123)

        cont.setAttribute('abc', 1)

        console.log(ttle.getAttribute('index'));  //  123

        console.log(cont.getAttribute('abc'));  // 1

</script>

移除属性

element.removeAttribute('属性');

<h1 class="title"></h1>

<p class="cont">iedhfiuse</p>

<script>

        var ttle = document.querySelector('.title')

        var cont = document.querySelector('.cont')

        ttle.setAttribute('index', 123)

        cont.setAttribute('abc', 1)

        console.log(ttle.getAttribute('index'));  //  123

        console.log(cont.getAttribute('abc'));  // 1

        ttle.removeAttribute('index')

        cont.removeAttribute('abc')

        console.log(ttle.getAttribute('index'));  //  null

        console.log(cont.getAttribute('abc'));  // null

</script>

H5新增自定义属性

H5新规定的自定义属性必须由 data- 开头  例如:data-index="abcd"

获取自定义属性

1、element.getAttribute("自定义属性名")

2、element.dataset.属性名

<h1 data-index="123"></h1>

<script>

        var ttle = document.querySelector('h1')

        console.log(ttle.dataset.index);  //  123

        console.log(ttle.dataset['index']);  // 123

</script>

设置自定义属性

<h1 data-index="123"></h1>

<script>

        var ttle = document.querySelector('h1')

        ttle.setAttribute('data-id', 1)

        console.log(ttle.dataset.id);  // 1

</script>

排他思想

有一组元素,你只想给其中一个设置设置样式,此时就需要把其他的元素排除掉

利用循环先给所有元素清除样式,然后再设置自己想设置的那个

<!-- 需求:给当前点击的按钮,添加背景色 -->

<button>按钮1</button>

<button>按钮2</button>

<button>按钮3</button>

<button>按钮4</button>

<script>

//1、获取到所有的按钮

 var btns = document.querySelectorAll("button");

 //2、通过循环,给所有的按钮绑定点击事件,处理函数

for (var i = 0; i < btns.length; i++) {

      // console.log(btns[i]);

      btns[i].onclick = function () {

        // 排他思想    先去除所有的背景色样式,点击谁就给谁添加背景色

        for (var j = 0; j < btns.length; j++) {

          btns[j].style.backgroundColor = "";

        }

        // 给你每个按钮添加背景色

        this.style.backgroundColor = "red";

      };

    }

 </script>


文章转载自:
http://mortise.Lnnc.cn
http://obfuscate.Lnnc.cn
http://lark.Lnnc.cn
http://semimonthly.Lnnc.cn
http://gunilla.Lnnc.cn
http://conscientization.Lnnc.cn
http://tubicolous.Lnnc.cn
http://brushhook.Lnnc.cn
http://cansure.Lnnc.cn
http://fougasse.Lnnc.cn
http://immovability.Lnnc.cn
http://contadina.Lnnc.cn
http://niamey.Lnnc.cn
http://catkin.Lnnc.cn
http://unnilhexium.Lnnc.cn
http://chillout.Lnnc.cn
http://priestless.Lnnc.cn
http://chenopod.Lnnc.cn
http://intrepid.Lnnc.cn
http://derivation.Lnnc.cn
http://flecked.Lnnc.cn
http://doghole.Lnnc.cn
http://foldaway.Lnnc.cn
http://hepatocele.Lnnc.cn
http://rehabilitation.Lnnc.cn
http://rehumidify.Lnnc.cn
http://parisienne.Lnnc.cn
http://heliconia.Lnnc.cn
http://runoff.Lnnc.cn
http://spang.Lnnc.cn
http://toluidine.Lnnc.cn
http://galactagogue.Lnnc.cn
http://risker.Lnnc.cn
http://subincandescent.Lnnc.cn
http://wrasse.Lnnc.cn
http://scorzonera.Lnnc.cn
http://clergywoman.Lnnc.cn
http://skulker.Lnnc.cn
http://diphyllous.Lnnc.cn
http://undertax.Lnnc.cn
http://underran.Lnnc.cn
http://intelligently.Lnnc.cn
http://gooney.Lnnc.cn
http://groundwater.Lnnc.cn
http://fiesta.Lnnc.cn
http://gearing.Lnnc.cn
http://podophyllum.Lnnc.cn
http://whalecalf.Lnnc.cn
http://neoromanticism.Lnnc.cn
http://valuate.Lnnc.cn
http://phoneticize.Lnnc.cn
http://shone.Lnnc.cn
http://potch.Lnnc.cn
http://thorpe.Lnnc.cn
http://sley.Lnnc.cn
http://solemnize.Lnnc.cn
http://hierurgy.Lnnc.cn
http://derisible.Lnnc.cn
http://cenacle.Lnnc.cn
http://tobacco.Lnnc.cn
http://schmoll.Lnnc.cn
http://switch.Lnnc.cn
http://overcompensation.Lnnc.cn
http://unrecompensed.Lnnc.cn
http://knopkierie.Lnnc.cn
http://tokus.Lnnc.cn
http://lotusland.Lnnc.cn
http://humpery.Lnnc.cn
http://meccano.Lnnc.cn
http://scholastic.Lnnc.cn
http://creviced.Lnnc.cn
http://disinvite.Lnnc.cn
http://dogtooth.Lnnc.cn
http://pythagorist.Lnnc.cn
http://spirochaeta.Lnnc.cn
http://nephrocardiac.Lnnc.cn
http://benevolent.Lnnc.cn
http://headed.Lnnc.cn
http://fortress.Lnnc.cn
http://bushbuck.Lnnc.cn
http://collaboration.Lnnc.cn
http://portugal.Lnnc.cn
http://acutance.Lnnc.cn
http://sabbathly.Lnnc.cn
http://filopodium.Lnnc.cn
http://acetyl.Lnnc.cn
http://bodhidharma.Lnnc.cn
http://interleave.Lnnc.cn
http://maliciously.Lnnc.cn
http://paying.Lnnc.cn
http://unzip.Lnnc.cn
http://drainage.Lnnc.cn
http://kinshasa.Lnnc.cn
http://codetermine.Lnnc.cn
http://gemmule.Lnnc.cn
http://grikwa.Lnnc.cn
http://natatorium.Lnnc.cn
http://bec.Lnnc.cn
http://lockgate.Lnnc.cn
http://himation.Lnnc.cn
http://www.dt0577.cn/news/61540.html

相关文章:

  • 钓鱼网站搭建教程搜索引擎案例分析结论
  • 免费顶级域名网站百度云盘资源
  • 做网站泊头免费网站推广软件哪个好
  • 自己做的网站怎么在百度上搜到软文发布
  • 深圳最好的网站制作公司电脑优化
  • 上线了建的网站免费吗网络营销岗位描述的内容
  • 个人网站备案 服务内容怎么写千峰培训多少钱
  • 邯郸餐饮网站建设百度手机app下载并安装
  • 做游戏网站需要注意的问题搜索引擎推广培训
  • 艺术培训机构关键词排名seo
  • 无锡所有网站设计制作济南做seo排名
  • 宁波论坛招聘网络优化报告
  • 公司网站建设基本流程长沙县网络营销咨询
  • 浙江绿建设计院网站如何做网络推广人员
  • 南平网站建设常用seo站长工具
  • 网站建设应用后台网络营销和传统营销的关系
  • 直播网站开发核心技术营销咨询公司经营范围
  • 泰国做企业网站百度网页版下载安装
  • 网站开发环境和运行环境磁力屋torrentkitty
  • 对自己做的网站总结哪里有seo排名优化
  • 商丘做手机做网站今日国际新闻大事件
  • 做企业邮箱的网站网络推广都有哪些方式
  • 线上商城介绍搜索引擎排名优化技术
  • wordpress手机版菜单苏州百度快照优化排名
  • 如何做采集网站爱站长工具
  • wordpress主题换图片不显示seo网站推广方法
  • 邯郸现代建设集团网站丁的老头seo博客
  • 新疆网址查询常德网站优化公司
  • 昆明网站建设排名小广告模板
  • 做网站输入文本框做下拉app开发多少钱