473,387 Members | 3,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Remove Div

Hello all of you,

I want to delete the div from the page how can i do that.
I tried this but it is not work.

the javascript function is as follows
Expand|Select|Wrap|Line Numbers
  1.         function removeEvent(divNum)
  2.         {
  3.             var d = document.getElementById('myDiv'); 
  4.             var olddiv = document.getElementById(divNum); 
  5.             d.removeChild(olddiv);
  6.         }
  7.  
and HTML tag is as below
Expand|Select|Wrap|Line Numbers
  1.           <td>
  2.         <span id="fill">
  3.         </span>
  4.     </td>
  5.  
though i had tried with div instead of span but it didnt work
whats the problem?
please rewrite the code

Thanks in advance.

-Mayur
Oct 15 '07 #1
3 13903
gits
5,390 Expert Mod 4TB
hi ...

i assume your 'myDiv' node is the parent of the posted span with the id = 'fill' but not the direct parent ... since the span seems to be enclosed by a 'td'? ... you have to retrieve that td-node and removeChild() the 'fill-span' from it ...

kind regards
Oct 15 '07 #2
mrhoo
428 256MB
Try this method, it will remove an element or a text node.
Pass a reference to the node you want removed, or an element id.


Expand|Select|Wrap|Line Numbers
  1. function removeWho(who) {
  2.     if(typeof who== 'string') who=document.getElementById(who);
  3.     if(who && who.parentNode)who.parentNode.removeChild(who);
  4. }
Oct 15 '07 #3
Try this method, it will remove an element or a text node.
Pass a reference to the node you want removed, or an element id.


Expand|Select|Wrap|Line Numbers
  1. function removeWho(who) {
  2.     if(typeof who== 'string') who=document.getElementById(who);
  3.     if(who && who.parentNode)who.parentNode.removeChild(who);
  4. }
Hi mrhoo,

Thank you very much for your help it reallly works fine for me.
and another thing i want to know is there any way to get that div that had been deleted far. i mean the div which user has deleted that i wanna back.

Mayur
Oct 16 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Sam Collett | last post by:
How do I remove an item with a specified value from an array? i.e. array values 1,2,2,5,7,12,15,21 remove 2 from array would return 1,5,7,12,15,21 (12 and 21 are NOT removed, duplicates are...
11
by: Tony Johansson | last post by:
Hello! I have some problem with STL function remove I have two classes called Handle which is a template class and Integer which is not a template class. The Integer class is just a wrapper...
6
by: Arne Claus | last post by:
Hi If've just read, that remove() on a list does not actually remove the elements, but places them at the end of the list (according to TC++STL by Josuttis). It also says, that remove returns a...
3
by: Don | last post by:
My user control has a combobox with an arraylist attached to it along with custom add and remove methods. The "Add" method is working great. However I don't understand why the "Remove" method...
3
by: Niyazi | last post by:
Hi all, I have a dataTable that contains nearly 38400 rows. In the dataTable consist of 3 column. column 1 Name: MUHNO column 2 Name: HESNO Column 3 Name: BALANCE Let me give you some...
6
by: tshad | last post by:
Is there a reason to use session.remove over session.contents.remove? Don't they both remove the key and data from the contents collection? I assume that session(x) = nothing does essentially...
7
by: Susan Mackay | last post by:
I have a data table that is connected to a database table with a data adapter in the 'standard' manner. However I want to be able to remove selected rows from the data table (i.e. no longer...
6
by: sam_cit | last post by:
Hi Everyone, I'm using remove() function to delete a file, and i observed the following behavior, Concerned file : sample.txt Operation : i open the file in read mode and don't close the...
10
by: =?Utf-8?B?YmJn?= | last post by:
Hi all, I wanted to go through each entry(?) of ArrayList and remove some particular entry. So I tried following but it throws exception at runtime: foreach (myEntry entry in myArrayList) {...
2
by: =?Utf-8?B?R3JlZw==?= | last post by:
I have the following code the dynamically adds a specific number of controls. for x as integer = 1 to 10 Dim btn as Windows.Forms.Button = New Windows.Forms.Button btn.Name = "btn" & x btn.Text...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.