Is it possible I can replace my name with "anonymous" via jquery. but still keep my anchor tag with the specific link to a comment. I couldn't figure it out so I tried removing the text and keeping the comment with
$('div.entryFooter').replaceWith($('div.entryFooter a'));
but it showed all the content from all three 'a' elements in all of my divs.
Ideally, I just need the name replaced with "anonymous". My name will always be different so I need a way to find the name after "Posted by"
<div class="entryFooter">Posted by mjroodt at 24/10/2011 11:48<a href="/BlogPage.aspxid=20396&blogid=58906">Comments (1)</a></div>
<div class="entryFooter">Posted by mjroodt at 27/10/2011 13:33<a href="/BlogPage.aspx?id=12396&blogid=58945">Comments (2)</a></div>
<div class="entryFooter">Posted by mjroodt at 27/10/2011 15:59<a href="/BlogPage.aspx?id=14396&blogid=59963">Comments (7)</a></div>
Many thanks
This loop will parse out the name, whatever it might be, and replace it with in this case anon:
Example
Using:
I'd suggest you to wrap text into span and iterate through them to change text() with RegExp:
see the work example for you requirements: http://jsfiddle.net/mikhailov/ypRsP/
HTML
JS
No need for jQuery here. Just use the Javascript
replace([substring], [newstring])
function:Should be noted that this is only for the visual display. If you don't want the names to show at all, you'll need to parse them out at the server or database level.
If you want to hide your real name, you have to adjust the server response.
For visual changes only, use the code below:
You could match any name and replace it with "anonymous" using the below code,
The above would replace the content between "by" and "at" in the sentence "posted by xyz at" by "posted by anonymous at".
You can do this by using a few lines of Jquery below. This solution will keep your anchor tags working as they were and you don't need to know the name you are trying to replace.
EXAMPLE