document.getElementById to include href

后端 未结 4 524
无人及你
无人及你 2021-01-07 07:08

What is the correct way to turn this into a link?

4条回答
  •  醉话见心
    2021-01-07 07:36

    You should specify what kind of element is IDOFELEMENT. But you can't convert it to a link by just adding a href attribute, it only works if IDOFELEMENT is an hyperlink like stuff

    Simplest way is to add an onclick event to the element that changes the url to desired address:

    
    

    Or if you wanna wrap it with a hyperlink:

    
    

    I hope this helps you.

提交回复
热议问题