replace anchor text with jquery

后端 未结 5 1080
无人共我
无人共我 2020-12-05 16:45

i want to replace the text of a html anchor:

Click to go home

now i want to replace the

5条回答
  •  心在旅途
    2020-12-05 17:21

    To reference an element by id, you need to use the # qualifier.

    Try:

    alert($("#link1").text());
    

    To replace it, you could use:

    $("#link1").text('New text');
    

    The .html() function would work in this case too.

提交回复
热议问题