javascript - How to change text on a page? (Find and replace using jQuery?) -


i have block of hardcoded, uneditable html:

<td id="v65-onepage-ordercomments-value" width="61%" valign="top" colspan="2">      order comments:&nbsp;(optional)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;      <br>                 <textarea name="order_comments" id="v65-onepage-ordercomments-input" rows="3" cols="55"></textarea> </td> 

i want replace "order comments (optional)", non-breaking spaces. preferably replace other html, header , paragraph tag. best way this? assumption find & replace using jquery?

it it's textnode first child of parent div, can :

var node = document.getelementbyid('v65-onepage-ordercomments-value').firstchild; node.nodevalue = 'new content'; 

fiddle

or in jquery:

$('#v65-onepage-ordercomments-value').contents().each(function() {     if (this.nodetype===3 && this.nodevalue.trim().length)          this.nodevalue = 'new content'; }); 

fiddle


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -