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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T03:54:15+00:00 2026-05-29T03:54:15+00:00

I am having an issue with a single line of javascript/jquery. I am attempting

  • 0

I am having an issue with a single line of javascript/jquery. I am attempting to select all objects with a given class and then create a trigger on another object using the id stored in the first objects class.

The JS/JQ:
$('.navs').click(function(){$("#"+$(this).attr('tab')+"").trigger('click');})

The HTML:
<img alt="" class="thumbnail" src="gamedev_thumb.png" class="navs" tab="gamedev"/>

I am not sure if this matters, but this code is in a page fragment that is loaded into a div on the main page. I have tabs at the top to control navigation, and for simplicity I would like the image to trigger a click on the appropriate tab on top.

  • 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-29T03:54:16+00:00Added an answer on May 29, 2026 at 3:54 am

    You have two times a class attribute. You can definitely put several class names within the same class attribute:

    <img alt="" class="thumbnail navs" src="gamedev_thumb.png" tab="gamedev"/>
    

    If the fragment is loaded with ajax after the page has loaded, unfortunately, your selector $('.navs') has already run and your image will not be part of it, you have to execute your piece of javascript after the fragment has loaded and been appended to the document.

    I don’t know how you load the fragment but one way is to use the callback of the .load() method if you used it:

    $('#mydiv').load(url, function() {
        $('.navs').click(function(){
            $("#"+ $(this).attr('tab') + "").trigger('click');
        })
    });
    

    Note that if you load a fragment with the load method (for instance “mypage.html #mydiv”), all javascript blocks will be removed.

    jQuery .load()

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

Sidebar

Related Questions

I am having an issue serializing a c# class to an XML file that
I'm having the famous segmentation fault. I've tracked it down to a single line
I'm having a pressing issue and I'm hoping you all can help me out.
I'm having an issue with a javascript interaction on a site, and I can't
Having an issue with random individuals trying to access an intranet site with a
Having an issue here that I have tried everything I can think of but
The issue I'm having is issue with is I'm trying to get the paintComponent
I'm having an issue with a query that currently uses LEFT JOIN weblog_data AS
I'm having an issue with my regex. I want to capture <% some stuff
I'm having an issue with a Flash/Flex erroring in Firefox but not IE. I

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.