0

I'm wondering how to get a string representation of an element created using jQuery

Something like this:

var myFrame = $("iframe",{src:"http://google.com" scrolling:"no"});

Resulting in: <iframe src="http://google.com" scrolling="no"></iframe>

instead of: [object Object]

I realize that I can create the string from the start, but for readability and the sake of being difficult, I'd like to know how to do it.

gin93r
  • 1,551
  • 4
  • 21
  • 39
  • 2
    You probably wanted `var myFrame = $(" – Denys Séguret Jul 28 '14 at 16:21
  • Yeah - I missed the < and > in this case but I did actually have the comma in my actual code. Thanks! – gin93r Jul 28 '14 at 16:23

1 Answers1

2

Take the outerHTML of the DOM element :

var html = myFrame[0].outerHTML;
Denys Séguret
  • 372,613
  • 87
  • 782
  • 758
  • Thanks! Combined with the missing < and >, that did the trick. Now to wait for the stupid 10 minute wait so that I can accept your answer. – gin93r Jul 28 '14 at 16:24