1

I have to replace Text inside HTML. When I looked ViewSource of the page I found this html tag. Now I need to replace text "Respuesta" with "Responder". I am using SharePoint CEWP webpart for this. What is the code I need write to replace this text?

<div><a id="ReplyLink3" href="" ONCLICK="javascript:GoToPage('');return false;" target="_self"><img id="replyButton" border="0" align="middle" alt="Respuesta" src="/_layouts/images/reply.gif">&nbsp;<NOBR><b>Respuesta</b></NOBR></a><
James123
  • 11,184
  • 66
  • 189
  • 343

2 Answers2

2

You asked specifically for jQuery, so here it is in jQuery ssuming there is no other bolded text. Uses the Next Siblings Selector. Only works if there are no more <b> items as children of the div.

$(document).ready(function() {
    $("$replyButton ~ b").text("Responder");
});
justkt
  • 14,610
  • 8
  • 42
  • 62
  • Do you any body know about Sharepoint? How can I put this code sharepoint page using CEWP? – James123 Apr 30 '10 at 17:03
  • Are you trying to statically update the word Respuesta (permanently for all time), or do it dynamically for some reason? If the former, just edit the page with CEWP. If the latter, then you need to find the Head of your webpage and add a script or external script. – justkt Apr 30 '10 at 17:38
  • I want permanently for all time. How can I find Head of the web page and your script please, direct me. – James123 Apr 30 '10 at 18:48
  • @James123 - doesn't sound like you want to use jQuery. Instead, it sounds like you want to edit the HTML - is that correct? If so, just remove Respuesta and write Responder. If you aren't familiar with editing using HTML, looks like there are some good CEWP tutorials out there if you Google. – justkt May 01 '10 at 00:50
1

Another approach using replace() JavaScript method:

$('#ReplyLink3').parent().html( $('#ReplyLink3').parent().html().replace(/Respuesta/gi,'Responder') );

You may need to optimize the selectors but this may be what you are looking for:

.replace(/Respuesta/gi,'Responder')
Xavi Esteve
  • 1,114
  • 2
  • 19
  • 35