0

I am describing some html elements as value of thickbox and its possible to fetch that elements inside textarea

Sample

<textarea id="txtarea_id"><div class="div_class">country</div></textarea>

I need to fetch the div element inside textarea

1

3 Answers 3

3
<!ELEMENT TEXTAREA - - (#PCDATA)       -- multi-line text field -->

http://www.w3.org/TR/html4/interact/forms.html#h-17.7

A textarea element can contain only PCDATA, no elements of any kind. The code you have presented is invalid HTML.

You could have the value of a textarea be some text that could be presented as HTML:

<textarea id="txtarea_id">&lt;div class="div_class"&gt;country&lt;/div&gt;</textarea>

… but the content can only be text, not elements.

You can fetch the data using jQuery's val() method (or just use the standard DOM .value).

Sign up to request clarification or add additional context in comments.

1 Comment

The question was ambiguous, I guess. OP said "I am describing some html elements as value of thickbox" and, in the end, "I need to fetch the div element inside textarea".
0

Use jQuery's .val()

alert($('#txtarea_id').val());

If you want to convert that text to an HTML element, use $ and wrap it like this.

$($('#txtarea_id').val());

Comments

0

you can not use HTML tags inside a textarea. It will be encoded and you will see "<div class="div_class">country</div>" as the default text in your textarea.

I am wondering why are you doing this?

You can give a class to the textarea and then define css for that class.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.