If you want to include HTML in your text area, you should be using a
function like PHP's "htmlentities()" on the inner contents of the HTML.
PHP:
<?php
$value = '<a href="/page">My Link</a>';
echo '<textarea id="content">' . htmlentities($value) . '</textarea>';
?>

Resulting HTML:
<textarea id="content">&lt;a href=&quot;/page&quot;&rt;My
Link&lt;/a&gt;</textarea>

Now the contents of your text area will be valid, and you can use jQuery to
get the value like you would any other form input:

JS:
$('content').value(); // returns <a href="/page">My Link</a>

That should make things easier to work with.

-Hector


On Mon, Nov 17, 2008 at 10:34 AM, Eric Martin <[EMAIL PROTECTED]> wrote:

>
> If you just want the "string" value, how about:
>
> var content = $("#content").val();
> content = content.replace(/ target=(\'|\")_(new|blank)(\'|\")/, "");
> content = content.replace(/ border=(\'|\")\d+(\'|\")/, "");
>
> -Eric
>
>
> On Nov 17, 10:18 am, cc96ai <[EMAIL PROTECTED]> wrote:
> > I have a text area in the following
> > <textarea cols="50" rows="5" id="content">
> > <a id="link" href="http://www.google.ca"; target="_new">test link</a>
> > <img src="images/test.jpg" border="1" vspace="2" alt="test">
> > </textarea>
> >
> > and I would like to strip out the hyperlink target, and image border,
> > and get the string of the HTML,
> > any idea on it?
> >
> > I try the following, but it only remove the hyperlink in the page, not
> > the hyperlink in textarea.
> >         $("a").removeAttr("target");
> >
> > Can I load the textarea 's content in jquery, then do the select/
> > remove the attribute and return as string?
> >
> > Thanks
>

Reply via email to