473,396 Members | 1,998 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,396 software developers and data experts.

Check for document ID?

Is there a way for Javascript to check if a document CSS id exist anywhere
on a page, for example, if "bla" exists?

<a href="asf" id="bla">

Jul 23 '05 #1
2 4342
var obj=document.getElementById('bla');
if (typeof(obj)=='undefined' ) alert('The object does not exist!'); // or
typeof(obj)!='object'

"michael" <no****@example.com> ????
news:cb*************@news.t-online.com...
Is there a way for Javascript to check if a document CSS id exist anywhere
on a page, for example, if "bla" exists?

<a href="asf" id="bla">

Jul 23 '05 #2
CryingClinton wrote:
var obj=document.getElementById('bla');
if (typeof(obj)=='undefined' ) alert('The object does not exist!');
// or typeof(obj)!='object'
The W3C Core DOM - getElementById - method is specified as returning -
null - when it cannot locate an element with a corresponding ID
attribute in the DOM. The - typeof - operator returns the string
"object" when its operand is - null - so neither of these tests will
work. A type-converting test would be more effective in this situation.
"michael" <no****@example.com> ????


Please do not top-post in comp.lang.javascirpt.

Richard.
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Edward | last post by:
The following html / javascript code produces a simple form with check boxes. There is also a checkbox that 'checks all' form checkboxes hotmail style: <html> <head> <title></title> </head>...
2
by: Mike | last post by:
I´ve got a number of SPAN elements named "mySpan1", "mySpan2", "mySpan3" etc, and want to set their "style.display" to "inline". This works (only needs to work on IE5.5+): for (var x = 1; x <...
2
by: Rtritell | last post by:
I dont get whats wrong with this <html> <head> <title>Random Mad Lib!</title> <script language="JavaScript"> <!-- Hide
1
by: vncntj | last post by:
i want to enable one listbox and disable the other depending on if i check winter_gala (checkbox) here is my code. <script type="text/javascript"> function check() { if...
9
by: Marc | last post by:
Okay, here's the problem - I have 3 radio buttons, and 11 check boxes (which are disabled by default). I have the javascript below which when the last radio button is clicked, enables the...
3
by: pollygw | last post by:
I have a page that dynamically adds rows to a table and the user can also delete any of the rows in no specific order. When the form is submitted I need to do some validation. I can't loop through...
0
by: =?Utf-8?B?U2FkaG5h?= | last post by:
HI , I am using MOSS 2007 API's to implement the version controls like check in and check out in Visual Studio 2005. I have a sharepoint 2007 server and i am accessing the MOSS API (on...
1
by: Anuj | last post by:
Hi, since sometime I'm stuck in a problem where I want to check or uncheck all the checkboxes. If I'm choosing name for the checkbox array as 'chkbx_ary' then I'm able to check/uncheck all the...
11
by: Patrick | last post by:
Trying this question again in a different way and expanding it to another newsgroup. Looking for how I would do this. For an html form; Say I have three check boxes A, B, and C . When I click...
3
by: ghjk | last post by:
I want to set read only for check box when I click submit button. But my code didn't work. This is my code java script code. document.getElementsById('check').disabled=true;...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
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,...
0
jinu1996
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...
0
tracyyun
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...

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.