2009/12/22 Šime Vidas <sime.vi...@gmail.com>

> Well, you selected BR elements, which are empty elements, so it's no
> mystery why this.innerHTML returns undefined...
>
> Also, DIVs shouldn't appear inside SPANs...
>

He did state that he's using generated HTML.  He has no control over it.

Mike - this isn't really a jQuery problem per se.  You're jQuery selectors
match DOM elements.  Not so much the contents of those elements.

What you can do is search for the containing element (in this case, you can
look for a <span> with a class of "event"), and replace all instances of <br
/>* with just the <br />.

$(document).ready(function() {
    var newHTML = $('span.event').html().replace(/(<br.*>)\s*\*/g, '$1');
    $('span.event').html(newHTML);
});

The expression is looking for a <br /> (or <br> or <br/>) followed by any
white space (including tabs), followed by an asterisk.  It replaces that
pattern with the <br /> alone (removing the asterisk).

Disclaimer: I'm no regex guru, so if anyone sees a way to clean up that
expression, please feel free.

-- 
Charlie Griefer
http://charlie.griefer.com/

I have failed as much as I have succeeded. But I love my life. I love my
wife. And I wish you my kind of success.

Reply via email to