Remove certain text from the title attribute

62 views
Skip to first unread message

lalov1

unread,
Mar 7, 2012, 12:06:51 PM3/7/12
to Prototype & script.aculo.us
Hello all,

I'm new to prototype and am trying to achieve the following. I have
the following title text "1:00 pm - 2:00 pm <a href="http://
www.google.com">Link Goes Here</a>"

I want to delete the "<a href="http://www.google.com">" and the "</
a>".

What is the best way to do this. Right now I'm using the
removeAttribute('title'); which works, but not like I want it to. Here
is a link to our page:
http://www.colostate-pueblo.edu/Communications/Events/Pages/default.aspx

Thank you,
Lallo

blechler

unread,
Mar 8, 2012, 3:03:42 PM3/8/12
to Prototype & script.aculo.us
Hi Lallo,

I'm not sure that I entirely understand what you are attempting to
accomplish and how removing the title attribute is working for you.
When I go to the provided page and attempt to inspect it, I see a lot
of title attributes being rapidly added and removed from the div
containing the calendar item.

Nevertheless, let's say you have the following:

<div class="ms-acal-item" id="foo">
<div class="ms-acal-sdiv">
7:00 pm <a href="/Communications/Events/Pages/eventdisplay.aspx?
EventID=2262">&#8203;Mayan Elder</a>
</div>
</div>

the following script will do what I think you want to accomplish:

<script>
function removeThatAnchor() {
var innerDiv = $('foo').select('.ms-acal-sdiv')[0];
var aToRemove = innerDiv.select('a')[0];
var aText = aToRemove.innerHTML;
aToRemove.remove();
innerDiv.update(innerDiv.innerHTML + " " + aText);
}
</script>

Bernard

On Mar 7, 12:06 pm, lalov1 <lallo.vi...@gmail.com> wrote:
> Hello all,
>
> I'm new to prototype and am trying to achieve the following. I have
> the following title text "1:00 pm - 2:00 pm <a href="http://www.google.com">Link Goes Here</a>"

lalov1

unread,
Mar 8, 2012, 6:59:36 PM3/8/12
to Prototype & script.aculo.us
I'm doing a hack and the link is showing up in the title attribute.

Here is my code which only removes the "</a>", but I need to remove
the opening href as well.
//Remove Title
titleLinks=$$('div.ms-acal-item');

for (var i = 0; i < titleLinks.length; i++) {
var element = $(titleLinks[i]);
if (element.hasAttribute('title')) {
var tempTitle = element.readAttribute('title');
tempTitle = tempTitle.gsub('</a>','');
element.setAttribute('title', tempTitle);
} else {
element.setAttribute('title', '');

john knepper

unread,
Mar 8, 2012, 7:02:25 PM3/8/12
to prototype-s...@googlegroups.com
lallo, can you elaborate on what you 'want' to do?

Victor

unread,
Mar 8, 2012, 7:34:55 PM3/8/12
to prototype-s...@googlegroups.com
I want to delete the "<a href="http://www.google.com">" and the "</ a>"

If I understood, you need to read about string operations and regular expressions in JavaScript, e.g. from https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/replace 
Reply all
Reply to author
Forward
0 new messages