Skip to content

Instantly share code, notes, and snippets.

@jnwheeler44
Created November 2, 2011 16:01
Show Gist options
  • Save jnwheeler44/1334019 to your computer and use it in GitHub Desktop.
Save jnwheeler44/1334019 to your computer and use it in GitHub Desktop.
Convert text to a dom element in jQuery
// Had an interesting problem today by trying to load a textarea's contents as dom elements.
// Here's what I did:
// get my value and convert into a dom element
var string = $('#article_body').val();
var element = $("<div>" + string + "</div>");
// from there, I can get what I need
element.find("video").attr('src');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment