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 7611985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:48:02+00:00 2026-05-31T01:48:02+00:00

I’m trying to select a specific class (in this case page1, page2, page3 etc.)

  • 0

I’m trying to select a specific class (in this case page1, page2, page3 etc.)

I’ve written this code that works fine for a single class, i’ve tried using .match() to exclude the .plink class picked up in dis but can’t get it working.

$(function(){
    $("a.plink").click(function() {
        var dis = $(this).attr("class");    // This is the problem line, I need it to contain 'page1' ONLY. Not 'page1 plink'.
        $("#page1,#page2,#page3").hide();
        $("#" + dis).show();
        return false;
    });
});

The HTML that is associated with this is:

<div id="page-links">
    <a class="page1 plink" href="#">About</a>
    <a class="page2 plink" href="#">History</a>
    <a class="page3 plink" href="#">Backstage</a>
</div>

EDIT:

These are the DIV’s being shown and hidden:

<div id="page1">
    <?php include_once("page1.php");?>
</div>
<div id="page2">
    <?php include_once("page2.php");?>
</div>
<div id="page3">
    <?php include_once("page3.php");?>
</div>

Is there a simple way to achieve this without regular expression matching?

  • 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-31T01:48:03+00:00Added an answer on May 31, 2026 at 1:48 am

    This should be

    $("." + dis).show();
    

    for class and in your example there are all classes.

    As you mentioned simple way so it could be

    $("a.plink").click(function() {
        $(".plink").hide();
        $(this).show();
        return false;
    });
    

    According to your question after edit

    $("a.plink").click(function() {
        $('div[id^="page"]').not('#page-links').hide();
        pid=$(this).attr('class').split(' ')[0];
        $('#'+pid).show();
        return false;
    });
    

    Here is a fiddle.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm trying to create an if statement in PHP that prevents a single post
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am doing a simple coin flipping experiment for class that involves flipping a
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.