quiero reemplazar el texto de un ancla html:
<a href="index.html" id="link1">Click to go home</a>
ahora quiero reemplazar el texto 'haga clic para ir a casa'
he intentado esto:
alert($("link1").children(":first").val());
alert($("link1").children(":first").text());
alert($("link1").children(":first").html());
pero todo me da nulo o una cadena vacía

Para hacer referencia a un elemento por id, debe usar el
#calificador.Tratar:
alert($("#link1").text());Para reemplazarlo, puede usar:
$("#link1").text('New text');La
.html()función también funcionaría en este caso.fuente
$('#link1').text("Replacement text");El
.text()método suelta el texto que usted pasa al contenido del elemento. A diferencia del uso.html(),.text()de manera implícita ignora cualquier incrustado HTML marcado, por lo que si necesita integrar alguna línea<span>,<i>o cualesquiera otros elementos similares, el uso.html()en su lugar.fuente
Prueba esto, en caso de id
$("#YourId").text('Your text');O esto, en caso de clase
$(".YourClassName").text('Your text');fuente
function liReplace(replacement) { $(".dropit-submenu li").each(function() { var t = $(this); t.html(t.html().replace(replacement, "*" + replacement + "*")); t.children(":first").html(t.children(":first").html().replace(replacement, "*" +` `replacement + "*")); t.children(":first").html(t.children(":first").html().replace(replacement + " ", "")); alert(t.children(":first").text()); }); }t.html(t.html()t.children(":first")Muestra
<a title="alpc" href="#">alpc</a>fuente