Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 重置html链接属性_Javascript_Html - Fatal编程技术网

Javascript 重置html链接属性

Javascript 重置html链接属性,javascript,html,Javascript,Html,我的html中有以下行 然后我使用chrome开发控制台将属性数据url更改为另一个链接。我可以在以后以某种方式将此链接重置为其默认值吗?我见过一个reset()函数,但我想它对这个问题不起作用。存储在另一个属性中 const anc=document.getElementById(“anc1”); anc.dataset.saveurl=anc.dataset.url; anc.dataset.url=“otherurl” 另一个完美的使用案例!您必须将原始值存储在某个位置。您可以添加另

我的html中有以下行



然后我使用chrome开发控制台将属性
数据url
更改为另一个链接。我可以在以后以某种方式将此链接重置为其默认值吗?我见过一个
reset()
函数,但我想它对这个问题不起作用。

存储在另一个属性中

const anc=document.getElementById(“anc1”);
anc.dataset.saveurl=anc.dataset.url;
anc.dataset.url=“otherurl”

另一个完美的使用案例!您必须将原始值存储在某个位置。您可以添加另一个数据属性,并将数据url设置回指定的值“编写一个函数,将您的缩略图重置为其原始数据url值,并随机更改另一个值”。有关更多上下文,请参阅。或者删除
data role=“trigger”
它看起来像是一个钩子,用来钩住正在改变它的东西,如果你想要原始的href,那么干脆不要添加它为什么不使用img标签?