On Dec 22, 12:09 pm, Charlie Griefer <charlie.grie...@gmail.com> wrote: > 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). >
[ ... snipped ... ] Thanks for pointing me in the right direction. This is what I ended up getting to work: jQuery("span.event", ".calendar-table").each(function(){ var html = this.innerHTML.replace(/(<br\s*\/*>)\s*\*/ g, \'$1\'); jQuery(this).html(html) ; }) ; I changed the regular expression slightly to eliminate the .* portion and changed .html() to .innerHTML. I don't know enough jQuery to know why I had to do that but had seen it elsewhere so tried it and it worked. Thanks, Mike