I’m trying to replace every instance of “Administrator” on my page with “Admin” Or something similar to that. How would I replace that? If it helps, the span is inside an tag that has the class “user-title”.
Like this page but I kinda need to be fed the answer. This is my first time working with javascript.
<ul class="author-ident">
<li class="username">
<a title="Go to Different55's profile" href="http://fwin.co.cc/pun/profile.php?id=2">Different55</a>
</li>
<li class="usertitle">
<span>Administrator</span>
</li>
<li class="userstatus">
<span>Online</span>
</li>
</ul>
I work mostly with JQuery so I can only give you a JQuery solution of the top of my head. Sorry if this is not an option for you. With JQuery you could do this…
NOTE: If you expect more than one instance of “Administrator” per span tag then you will need to do a regex replace like follows…
See this for more info on the regex flag (e.g. “g” means global – more than one)
EDIT: Here is a javascript version….
ANSWER: This is based on your provided sample HTML (note that I have changed the class name “usertitle” based on your html, check if this is correct)…
The JQuery equivalent…