700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > js判断是由含有a节点_js获取HTML元素节点方法

js判断是由含有a节点_js获取HTML元素节点方法

时间:2019-12-19 05:50:17

相关推荐

js判断是由含有a节点_js获取HTML元素节点方法

Javascript

获取网页中

HTML

元素的集中方法分析

getElementByIdgetElementsByNamegetElementsByTagName

大概介绍

getElementById

getElementsByName

getElementsByTagName

后两个是得到集合,

byid

只是得到单个对象

getElementById

的用法

举个例子:

网页陶吧

a>

同一页面内的引用方法

:

1

、使用

id

link1.href

,返回值为

2

、使用

name

document.all.linkname1.href

,返回值为

3

、使用

sourseIndex

document.all(4).href//

注意,前面还有

HTML

HEAD

TITLE

BODY

,所以是

4

4

、使用链接集合:

document.anchors(0).href

//

全部的集合有

all

anchors

applets

areas

attributes

behaviorUrns

bookm

arks

boundElements

cells

childNodes

children

controlRange

elements

emb

eds

filters

forms

frames

images

imports

links

mimeTypes

options

plugi

ns

rows

rules

scripts

styleSheets

tBodies

TextRectangle

,请参考

MSDN

介绍。

其实方法

3

和方法

4

是一样使用的集合,只是一个是

all

,可以包括页面所有标记,而

anc

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。