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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:02:18+00:00 2026-06-18T02:02:18+00:00

OK so I was using a bit of jquery to select all the <a>

  • 0

OK so I was using a bit of jquery to select all the <a> tags on the page and if they link to an image file to add a zoom class to it for the purposes of a lightbox.
This is the code which works

$(document).ready(function () {
$('a[href*=".png"], a[href*=".gif"], a[href*=".jpg"]').addClass('zoom');
});

There is a problem with this though;

Say I have a link which just goes to another page but passes an image url as a GET variable in the URL the lightbox is activated as a result of this and fails because the link is not actually to an image. For example:

<a href="http://example.com/a-normal-page/?pic=http://example.com/pics/picture.jpg">Link text</a>

In the above instance the jQuery script will add the zoom class to this anchor even though it doesn’t actually link to a picture.
This wouldn’t usually be an issue as you would leave the page to go to the link’s destination before the lightbox has a chance to appear, but in times where a new tab/window is opened I get a failed lightbox coming up.

This is particularly prevalent on social media buttons such as Pinterest which passes an image url within the link.

[apologies for the title – I wasn’t sure how best to phrase it. Please feel free to edit to something more suitable]

  • 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-18T02:02:20+00:00Added an answer on June 18, 2026 at 2:02 am

    you could add the zoom class only if href attribute doesn’t contain a ? (or, in other words, a querystring is not included), e.g.

    $(document).ready(function () {
        $('a[href*=".png"], a[href*=".gif"], a[href*=".jpg"]').each(function() {
            if (this.href.indexOf('?') < 0) {
                 $(this).addClass('zoom');
            }
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using a bit of jquery code which uses li items to select which
I'm having a bit of a difficulty using jQuery to bind a function to
I'm using the tag-it library for jquery to make a tagging system (a bit
I'm having a bit of trouble with jQuery Deferred. I'm using a jQuery ajax
I am trying to call to the bit.ly URL shortening service using jQuery with
For my shopping cart I'm using a bit of javascript to update my select
Can we Make a checkboxList using jquery like we fill the options in select
I am using jQuery to convert a bunch of SELECT elements to RADIO buttons.
I'm using this jquery plugin to make my select dropdown boxes look nicer. http://code.google.com/p/select-box/
I am using the Quicksand jquery scripts on an HTML page and using simple

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.