Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
Old 03-08-2004, 05:57 PM count <hr>'s with JS
c2k
c2k's Avatar
Skilled Talker

Posts: 72
Location: Germany
Trades: 0
Hi guys,
I have some <hr>'s on my site and would like to change some properties of them for different browsers.

But first of all I would like to count the number of <hr>'s and my question simply is how to count them?

Anyone ideas? It is for NN and Mozilla as well so the all object won't work

Thanks for you help!
c2k
c2k is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-09-2004, 08:20 PM
Christopher's Avatar
Iced Cap

Latest Blog Post:
Cross-domain AJAX with JSONP
Posts: 3,110
Location: Toronto, Ontario
Trades: 0
You could use this:

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
	<title>My Page</title>
	<script language="javascript">
	function count_them()
	{
		var num_tags = document.getElementsByTagName('hr');
        num_tags = num_tags.length;

        alert('Number of HR\'s: ' + num_tags);
	}
	</script>
</head>
<body onload="count_them()">

<hr />
<hr />
<hr />
<hr />
<hr />
<hr />
<hr />
<hr />
<hr />
<hr />

</body>
</html>
__________________

Please login or register to view this content. Registration is FREE
- Latest Articles:
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE

--
Please login or register to view this content. Registration is FREE

Christopher is offline
Reply With Quote
View Public Profile
 
Old 03-10-2004, 03:14 PM
c2k
c2k's Avatar
Skilled Talker

Posts: 72
Location: Germany
Trades: 0
Thanks alot.
I wasn't aware of being able to use this line
Code:
var num_tags = document.getElementsByTagName('hr');
Thanks alot. That helped!
c2k is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to count <hr>'s with JS
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.11337 seconds with 12 queries