Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8815303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:20:34+00:00 2026-06-14T04:20:34+00:00

I’m using the Wikipedia API to fetch just the first para of an article

  • 0

I’m using the Wikipedia API to fetch just the first para of an article for which a keyword has been provided.

I have to extract formatted text from the JSON response but suppress some of the unwanted info like the sidebar (which is in a table & has the class name infobox) before I show it in a div whose id is wiki –

$.getJSON("http://en.wikipedia.org/w/api.php?" +
            "action=mobileview&format=json&page=" +
            keyword + "&redirect=no&sections=0&prop=text&" +
            "sectionprop=toclevel%7Clevel%7Cline%7Cnumber" +
            "%7Cindex%7Cfromtitle%7Canchor&callback=?",
          function(json) { 
                    $('#wiki').html(json.mobileview.sections[0].text)
                              .find("dl,sup,.thumb,table.infobox,table.metadata")
                              .remove().end(); 
          }
);

I’ve adapted the jQuery trick to remove tags/selectors from the JSON response containing the HTML code of the requested Wikipedia page. I want to use the above snippet in a Windows 8 Store app written in HTML/JS. I wish to convert the following line to native JavaScript and implement the selector removal code without using jQuery –

$('#wiki').html(json.mobileview.sections[0].text)
           .find("dl,sup,.thumb,table.infobox,table.metadata")
           .remove().end(); 

I’m a JavaScript newbie. Can anyone please convert this line to plain-vanilla JavaScript?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T04:20:35+00:00Added an answer on June 14, 2026 at 4:20 am
    var wiki = document.querySelector('#wiki');
    wiki.innerHTML = json.mobileview.sections[0].text;
    
    var content = wiki.querySelectorAll("dl,sup,.thumb,table.infobox,table.metadata");
    
    for (var i = 0; i < content.length; i++) {
        if (content[i].nodeName.toUpperCase() === "A")
            content[i].parentNode.insertBefore(content[i].firstChild, content[i]);
    
        content[i].parentNode.removeChild(content[i]);
    }
    

    This will work in most browsers including IE8 and higher.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array which has BIG numbers and small numbers in it. I
I'm making a simple page using Google Maps API 3. My first. One marker
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have an autohotkey script which looks up a word in a bilingual dictionary
I have a text area in my form which accepts all possible characters from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.