Yeah, I wasn't really sure it would work, but thought it was worth a try.

And the <br/> <br> thing I think depends on the browser used and the
rendering mode it's forced into. What doctype are you using?

And for some more thought, Firefox (using <!doctype html>) renders <br> as
<br>, but IE8 will show them as <BR>, so.. see what you're getting and do a
replace on all possible combos, that's my thought.

Hope that helps.
T.J.

On Wed, Dec 9, 2009 at 11:02 AM, Mad-Halfling <mad-halfl...@yahoo.com>wrote:

> Thanks for the suggestions folks, I tried
> var $html = $("#DivID").html();
> $("br", $html).replaceWith("\r\n");
> but it doesn't seem to work, but it's something like that I thought I
> might be able to get funky and do - I had a look at the JQ homepage
> docs, but as you can see they are a little sparse in the different
> ways of using the methods beyond the basics - can anyone else think of
> a way, or is that (as I suspect) not what they are intended for?
>
> WRT replace and
> >> jQuery is not the answer for everything, sometimes simple JavaScript
> >>(which deep down jQuery is using anyways) is the solution
>
> I think a regex is the way to go, if there isn't any neat way of doing
> it with replaceAll/With as I mentioned above, as the brs seem to be
> slightly odd - I put them in as <br /> but if I alert() the div's html
> () they come out as <BR>
>
> On Dec 9, 4:11 pm, MorningZ <morni...@gmail.com> wrote:
> > "but I can't quite get my head around how to use those methods"
> >
> > The docs:
> >
> >
> http://docs.jquery.com/Manipulation/replaceWithhttp://docs.jquery.com/Manipulation/replaceAll
> >
> > would be the place to understand those methods, which just reading the
> > first few lines of each
> >
> > "Replaces the elements matched by the specified selector with the
> > matched elements"
> > "Replaces all matched elements with the specified HTML or DOM
> > elements"
> >
> > makes it pretty clear they are not for simple text replace...
> >
> > $('#TextAreaID').val($('#DivID').html().replace("<br />", ""));
> >
> > jQuery is not the answer for everything, sometimes simple JavaScript
> > (which deep down jQuery is using anyways) is the solution
>

Reply via email to