473,581 Members | 2,233 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get Tag Name

247 Recognized Expert New Member
hi all,

does anyone know how i can get the tagtype based on id?

Expand|Select|Wrap|Line Numbers
  1. <div id="foo"><p id="bar">test</p><img id="hi" src="hi.jpg"/></div>
  3. alert(getTag("foo"));  //would return 'div'
  4. alert(getTag("bar"));  //would return 'p'
  5. alert(getTag("hi"));  //would return 'img'
does anyone know how this can be done?
Apr 10 '09 #1
4 13560
16,027 Recognized Expert Moderator MVP
Use document.getEle mentById() to get the element and then use the tagName property to get the tag name/type.
Apr 10 '09 #2
247 Recognized Expert New Member
i didn't know that property existed.
sorry for the basic question and thanks acoder :)
Apr 10 '09 #3
8,658 Recognized Expert Moderator Expert
a quick overview what properties are on element nodes.
Apr 10 '09 #4
247 Recognized Expert New Member
ty Dormilich. that's very usefull :)
Apr 10 '09 #5

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

Similar topics

by: stewart.midwinter | last post by:
No doubt I've overlooked something obvious, but here goes: Let's say I assign a value to a var, e.g.: myPlace = 'right here' myTime = 'right now' Now let's say I want to print out the two vars, along with their names. I could easily do this: print "myPlace = %s, myTime = %s" % (myPlace, myTime)
by: Ravi | last post by:
My XML looks like: <abc> <def type="apple"> 1 </def> <def type="peach"> 2 </def> <def type="orange"> 3 </def> <def type="banana"> 4 </def> <def type="plum"> 5 </def> </abc>
by: discomiller | last post by:
Mario Mueller: Hello *, radiobuttons belong to other radiobuttons by the "name="any_value"" attribut. Thats a fakt. I got the following XML: **************************************************************
by: TheKeith | last post by:
I heard that the name attribute is deprecated in html 4.01 strict. Is it recommended that you use the ID attribute for images along with the getElementById method instead of the old way? Thanks.
by: CJ | last post by:
Why won't this work? I am passing the name of the form (I have two that use this validation script) but I keep getting an error. Error reads: "document.which_form.name is null or not an object" HTML----------- Form is ----> <form action="thanks.php" method="post" name="contact_form" id="contact_form"> Name -------> <input type="text"...
by: Andrew Thompson | last post by:
I have written a few scripts to parse the URL arguments and either list them or allow access to the value of any parameter by name. <http://www.physci.org/test/003url/index.html> <http://www.physci.org/test/003url/index.html?url=http://mybiz.com/&that=this&when=now#21>...
by: jparulan | last post by:
Hi All, I'm using SOAP3.0. I was able to successfully call a WSDL file and get a value properly. But when the WSDL changed to have a MULTIPLE <element name> it was failing. This code works BEFORE: strCurrency = oSOAP.eServeSearch(CSTR(Request.Form("T1"))) until the WSDL file changed to have more <element name> T1 is just a field that...
by: ivanet | last post by:
Hello everyone, I am trying to use the following Schema but I get the error "src- resolve: Cannot resolve the name 'ValuesList' to a(n) 'element declaration' component." at line 144. I have been reading http://www.w3.org/TR/xmlschema-1/#src-resolve, but I don't get what is wrong. Can anyone give me a hint? Thanks in advance.
by: pythonnewb | last post by:
I am fairly new to programming but have some very basic Java background. I am just learning python and tried to make a module that would allow me to create a file containing an address book. I was planning to then create a program to detect input and use this module, but I am hung up. I have constructed the code that I thought would work (though...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.