there is a html code like this:
<a href="http://domain.xxx?a=b&c=d" >text</a>
and when I use the dom api to get the href attribute.
document.querySelector('a').href
Why is the value of href
property different from attribute value?
http://domain.xxx/?a=b&c=d
alert(document.querySelector('a').href)
<a href="http://domain.xxx?a=b&c=d" >text</a>
use the Jquery instead
Suppose your anchor tag is look like below
<a id="anchorTag" href="http://domain.xxx?a=b&c=d" >text</a>
Use the Jquery below
$("#anchorTag").attr("href");
This will return the href value
Let me know if it is helpful
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.