hankknight
asked on
jQuery: Create Parent for Element
Using jQuery, how can I put #world INSIDE #hello?
I want to create a div with an id of "hello" around this:
I want to create a div with an id of "hello" around this:
<p id="world"></p>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Demo</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
alert('Create div with id of hello and place #world inside it');
// <div id="hello"><p id="world">Foobar/p></div>
});
</script>
</head>
<body>
<p id="world">Foobar/p>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.