Click here to Skip to main content
15,901,853 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hii All,

Is it possible to search for a dynamically inserted tag through DOM?.
For example, in my html page if I create a "video" tag(using document.createElement("video")), is it possible to check through DOM whether that tag is included in the page or not? If possible how will I do that?

Thanks.....
Posted
Updated 21-Jun-10 2:11am
v2
Comments
Sandeep Mewara 21-Jun-10 8:24am    
Updated my answer with couple of links, that should get you going.

vinodkalanji wrote:
is it possible to check through DOM whether that tag is included in the page or not?

Yes! you can.

Once they are the part of the document page, they are accessible in DOM.

=====
UPDATE:
Once you create a tag, you need to add that tag to any existing previous tags. Once done, you should be able to traverse it out.

Look here:
Add and Remove HTML elements dynamically with Javascript[^]
Dynamic DOM content[^]
 
Share this answer
 
v2
Comments
vinodkalanji 21-Jun-10 8:14am    
Hi Sandeep,
Can you please tell me how will I do that? Basically I have to confirm whether a dynamically inserted "video" tag is there or not in my page. If it is there then I have to take some actions..

Thank you....
as Sandeep Mewara says,

document.createElement this create a just an object instance (element) not inserted yet in DOM,
for to add/insert it, you need to use appendChild in desired element parent example :

0) you have a Div with id = "VidzArea"
1) you get reference of this DIV by using document.getElementById

2) now DIV (VidzArea) is your desired parent
3) and finally you add it your Video element created by document.createElement
 
Share this answer
 
Comments
Adrabi Abderrahim 21-Jun-10 9:01am    
sorry
3) and finally you add *your Video element* created by document.createElement to desired parent
vinodkalanji 23-Jun-10 1:38am    
Hi Sandeep...Thanks a lot ..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900