Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-21-2009, 01:44 AM   PM User | #1
php_guest
New Coder

 
Join Date: Jun 2009
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
php_guest is an unknown quantity at this point
jquery-delete everything inside div, but not the div

I have one simple question. How to delete everything inside div?
I know how to delete it together with div
Code:
$("#test").remove();
but I don't looking for that because I want that <div id="test"></div> stay there.

Thank you
php_guest is offline   Reply With Quote
Old 06-22-2009, 10:07 AM   PM User | #2
Spudhead
Senior Coder

 
Spudhead's Avatar
 
Join Date: Jun 2002
Location: London, UK
Posts: 1,856
Thanks: 8
Thanked 110 Times in 109 Posts
Spudhead is on a distinguished road
$("#test").children().remove();

?
Spudhead is offline   Reply With Quote
Old 06-22-2009, 11:56 PM   PM User | #3
Iszak
Regular Coder

 
Iszak's Avatar
 
Join Date: Jun 2007
Location: Perth, Western Australia
Posts: 332
Thanks: 2
Thanked 58 Times in 57 Posts
Iszak is an unknown quantity at this point
You could also possibly use.
Code:
$('#test > *').remove();
Not sure which is faster though.

Or alternatively..
Code:
$('#test').html('');
Iszak is offline   Reply With Quote
Old 06-23-2009, 05:09 AM   PM User | #4
Sleeping_Troll
New Coder

 
Join Date: May 2009
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Sleeping_Troll is an unknown quantity at this point
You could use prototype, test for child first to prevent error...
if($('yourdiv).down){
$('yourdiv).down.remove()
}
iterate to remove all children.
Sleeping_Troll is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:51 AM.


Advertisement
Log in to turn off these ads.