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

  • SEARCH
  • Home
  • 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 6797823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:39:23+00:00 2026-05-26T18:39:23+00:00

How can I load div content from external file, but also use a case

  • 0

How can I load div content from external file, but also use a case statement in the process? Might there be something with my Jquery code? Actually.. I’m confused??

JQuery Code:

$('.click-test').click(function() {
switch (this.id) {
case "test":
$('#test').load('external-file.html #test');
  break;

  case "test2":
  etc..
  });

html page:

<div class="click-test" id="test">click test</div>
<div id="test">place words from external file here</div>

external file .html

<div id="test">some words</div>
  • 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-05-26T18:39:23+00:00Added an answer on May 26, 2026 at 6:39 pm

    The jquery code is basically correct. The “this” does refer to the HTML element as you suspected and is set. So, your switch is working.

    <div class="click-test" id="test">click test</div>
    

    However, you’ve got 2 div’s in your base HTML page that both have the ID of “test”. Every ID should be unique on an HTML page (including the content you’re loading). So, you’ll need to do a bit of refactoring.

    You could for example change the HTML to:

    <div class="click-test" data-loadid="test">click test</div>
    

    And the JavaScript to:

    $('.click-test').click(function() {
        switch($(this).attr("data-loadid")) {
    

    This would read from an attribute named ‘data-loadid’ using the jQuery attribute function. Then you can proceed to load the external div content using load as you had done. (Although, you may want to remove the bookmark as it’s unnecessary?)

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

Sidebar

Related Questions

Here is my case: I use some external source to load html data to
Is it possible to use fancybox to load a specifc div #id from another
After load content to page using div.load('page.php'); I need get all of links from
I want to load in <div class=test> some content from another URL ex: http://someurl.com/default.aspx
Good evening everyone, I am using a JavaScript to load/override content from an HTML-File
I use this code to load the content from a different page into the
So...um, how can I load a specific DIV from a page loaded via ajax?
Using jquery.load() to replace the content of a div everything works great, however there
I'm trying to load content from another page div into another page div. What
I'm creating a div with jquery, loading content from webserver with load, and then

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.