/    Sign up×
Community /Pin to ProfileBookmark

TypeError: this.getElementsByTagName is not a function

Hello I keep getting this error

TypeError: this.getElementsByTagName is not a function

the part of the code that this is refering to is required by my teacher. here is my code that is giving me the problem, I am new to javascript and my teacher is not very helpful so any kind of help is appreciated.

function showSlide(){

var slideList=this.getElementsByTagName(“ul”)[0];

if((currentSlide!=null)&(currentSlide=slideList)){

closeSlide();}
else{
currentSlide.style.display=”block”;
timeID=setInterval(“moveSlide()”,1);

}}

here are the instructions for this part of the code

  • 6. Add the showSlide() function to the file. The purpose of this function is to display a
    sliding menu on the Web page. In the first line of the function, create a variable
    named slideList that stores an object reference to the first ul element nested within
    the current object (as referenced by the this keyword).

  • 7. Add an if statement to the showSlide() function. The purpose of the if statement is to
    test whether a sliding menu is currently displayed on the page. If the currentSlide
    object is not equal to null and the ID of the currentSlide is equal to the ID of the
    slideList variable, then run the closeSlide() function; otherwise, do the following:
    a. Run the closeSlide() function.
    b. Set the currentSlide variable equal to the slideList variable.
    c. Set the display style of the currentSlide variable to block.
    d. Run the moveSlide() function repeated at intervals of 1 millisecond. Store the ID
    of the timed function in timeID.
  • again any kind of help is appreciated even if it is to a link that may give me more information than my book.

    to post a comment
    JavaScript

    2 Comments(s)

    Copy linkTweet thisAlerts:
    @Logic_AliFeb 27.2013 — How is showSlide called?
    Copy linkTweet thisAlerts:
    @JMRKERFeb 27.2013 — In this statement:
    <i>
    </i>var slideList=this.getElementsByTagName("ul")[0];

    ...what is the 'this' referring to? The document? The function? The 'ul'?
    ×

    Success!

    Help @newjava 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 6.17,
    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: @nearjob,
    tipped: article
    amount: 1000 SATS,

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

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,
    )...