KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm trying to use jQuery to find the text within H1 then use this to replace the text already in foo2. Example below: <!DOCTYPE html> <html> <head> <script src="http://code.jquery.com/jquery-latest.js"></script> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Take text from element</title> <script type="text/javascript"> var str = $("h1").text(); $("#foo2").html(str); $("#foo2").replaceWith( str ); </script> </head> <body> <div id="foo"><div id="foo2">replace with h1</div></div> <h1>Text I want to take</h1> </body> </html>
Tags (comma-separated)
Save Edits
Cancel