1

There is a div with id="upper_div". I have a script linked to my HTML page. Inside the script I have another div with id="lower_div". I want to use the div inside the script.

i.e I want to append the lower_div with upper_div. I'm not able to get the div inside the script.

<div id="upper_div"></div>

<script src="test.js" method="get" type="text/javascript">              
<div id="lower_div>
<p>"Test"</p>
</div>
</script>

any suggestions?

2 Answers 2

2

use this

var html = "<div id='lower_div'><p>Test</p></div>";
$('#upper_div').append(html);
1

If you're using jQuery the following will work:

$('div#upper_div').append('<div id="lower_div"><p>"Test"</p></div>');

Here is a jsfiddle for you.

1
  • 1
    $('#upper_div') is much faster than $('div#upper_div') Commented Apr 25, 2011 at 11:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.