How to change the href for a hyperlink using jQuery

前端 未结 12 2126
孤街浪徒
孤街浪徒 2020-11-21 11:15

How can you change the href for a hyperlink using jQuery?

12条回答
  •  攒了一身酷
    2020-11-21 11:45

    Stop using jQuery just for the sake of it! This is so simple with JavaScript only.

    document.querySelector('#the-link').setAttribute('href', 'http://google.com');
    

    https://jsfiddle.net/bo77f8mg/1/

提交回复
热议问题