/    Sign up×
Community /Pin to ProfileBookmark

Need Help!!!!!!!!!!!!!!!

Can anyone tell me what I am not getting? I thought this code would work, but it isn’t. Here is the code:

[COLOR=Red]function Hide() {
myArray = document.getElementsByTagName(“DIV”);
DivArray = myArray.slice(3,-1);
alert (“There are ” + DivArray.length + ” divs.”);
}[/COLOR]

I have it being accessed with an “onClick” command. When it is accessed IE gives me an error for “DivArray = myArray.slice(3,-1);” saying, “Object doesn’t support this property or method”. Please help!!!!!!!!!!!! I currently have 7 DIV tags on my page.

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@FangJun 13.2005 — You can not [I]slice[/I] an object array.

What do you want to find?
Copy linkTweet thisAlerts:
@DizzyD69CamauthorJun 13.2005 — I want to seperate some of the Div tags so that I can run a loop to check the [B]style.display[/B], if block change to none. But I only want to do it with a few of them. I also have another script running that uses the ID of the DIV tag:

[COLOR=Red]function Toggle(item) {

obj=document.getElementById(item);

visible=(obj.style.display!="none");

if (visible) {

obj.style.display="none";

} else {

obj.style.display="block";

}

}[/COLOR]
Copy linkTweet thisAlerts:
@FangJun 13.2005 — Use a for loop:
<i>
</i>var aDIV = document.getElementsByTagName("DIV");
for(var i=3; i&lt;aDIV.length-1; i++) {
aDIV[i].style.display=(aDIV[i].style.display!="none")? "block" : "none";
}
Copy linkTweet thisAlerts:
@DizzyD69CamauthorJun 13.2005 — Thanks for the direction. I got it it working.
×

Success!

Help @DizzyD69Cam spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...