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: (optional) <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';
or in jquery:
$('#v65-onepage-ordercomments-value').contents().each(function() { if (this.nodetype===3 && this.nodevalue.trim().length) this.nodevalue = 'new content'; });
Comments
Post a Comment