Alex Rivera | Logout

How to get html of cloned element

Asked 2011-07-25T19:57:16.220
9

I have an input element like: <input class="input-m" name="formelement[]" type="text">

I want to clone it and store cloned html to a variable:

var txt=jQuery("input[name="+n+"[]]:first").clone().html();

this returns an empty string.

How can I get the html content from .clone()?

Edit
Report

1 Answer

1

.html() returns the html inside the element. I am guessing you have something like <input name="..."/> which has no inner html.

You should probably rely on something like outerHtml plugin.

answered 2011-07-25T20:01:02.163

Your Answer