How can I add “href” attribute to a link dynamically using JavaScript?

前端 未结 5 1232
不思量自难忘°
不思量自难忘° 2020-11-27 14:43

How can I add the href attribute to a link dynamically using JavaScript?

I basically want to add a href attribute to

5条回答
  •  北荒
    北荒 (楼主)
    2020-11-27 15:12

    More actual solution:

    Link
    
    const a = document.querySelector('#someId');
    a.href = 'url';
    

提交回复
热议问题