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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:58:46+00:00 2026-05-23T15:58:46+00:00

I have a jQuery tabbed search script that gets content from a PHP file

  • 0

I have a jQuery tabbed search script that gets content from a PHP file defined by the link and parses it to the results div element. The ID for each link is used to pull content from the correct file however type_ is needed in the link ID for the tabs to work which then doesn’t pull content from the right place. How can I resolve this issue?

This is my current jQuery code:

$(document).ready(function(){
    $("[id^=type_]").click(function(){
        type=$(this).attr("id");
        $("[id^=type_]").removeClass("selected");
        $("#"+type).addClass("selected");
        return false;
    });
    $("#type_tab1").click();
    $("#query").keyup(function(){
            var query=$(this).val();
            var yt_url=''+type+'.php?q='+query;
            if(query==''){
                  window.location.hash='';
                  document.title='My Search Script';
            }
            $.ajax({
                type:"GET",
                url:yt_url,
                dataType:"html",
                success:function(results){
                   $('#results').html(results);
                }
            });
    });
});

This is my HTML code:

<ul> 
<li><a id="type_tab1" href="javascript:void(null);">Tab1</a></li> 
<li><a id="type_tab2" href="javascript:void(null);">Tab2</a></li> 
<li><a id="type_tab3" href="javascript:void(null);">Tab3</a></li> 
</ul>
  • 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-23T15:58:47+00:00Added an answer on May 23, 2026 at 3:58 pm

    If I’ve understood your question correctly, you want to use only the part after the underscore character when you send your GET request.

    If that’s the case, you can do this in your click event hander:

    type=$(this).attr("id").replace("type_", "");
    

    Note that you can simplify this, because you don’t need to use jQuery to get the id attribute:

    type=this.id.replace("type_", "");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some jQuery code. I have called an Ajax function file, file.php, that
I am using jquery tabs to load content from a remote file. I have
I have written jQuery code, in files Main.html and ajax.php . The ajax.php file
I have a tabbed jquery slider that I'm using to display elements of an
I have some html/jQuery that I am using to implement some tabbed navigation. When
I have some jQuery/JavaScript code that I want to run only when there is
I have a jQuery datepicker that I want to restrict non work days -
I have this jQuery code that queries an API on a keyup event (via
I have created a tabbed display with html/css. I simply want to use jQuery
I have a site that has a div with content and a navbar (looks

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.