简体   繁体   中英

How to get attribute of tag using javascript?

Sorry if my question was stupid. please someone one tell me how to do this following issue. I have tags like shown below

<link rel="next" href="#" >
<link rel="prev" href="#" >

now i need to select this tag by using where rel has next and where tag rel has prev eg: rel="next"

getElementbyAttribute(rel="next").href ="www.yyyy.com"

getElementbyAttribute(rel="prev").href ="www.mmmm.com"

How to do this in javascript

您可以使用document.querySelectordocument.querySelectorAll来获取所有匹配的元素:

document.querySelector("[rel='next']");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM