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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:50:03+00:00 2026-05-26T15:50:03+00:00

In this scenario (your basic catalog), there are multiple <div> s, each containing an

  • 0

In this scenario (your basic catalog), there are multiple <div>s, each containing an item photo and some text. The item photo is a link. One can click the photo, and the link takes you to that item …

<div class="itembox">
    <a href="/100"><img src="item_100.jpg"></a>
    Item 100
</div>
<div class="itembox">
    <a href="/101"><img src="item_101.jpg"></a>
    Item 101
</div>

And consider this jquery:

$('.itembox').click(function(){
    window.location.href = $('a:first',this).attr('href');
});

With this, clicking “Item 100” will trigger the link. However, I don’t want to interfere with the standard “click a link” behavior (when the image is clicked) because users ofter press modifier keys to open a page in a new tab, and each browser seems to handle javascript opened windows differently.

So… how does one open a window ONLY of the user clicks something that ISN’T a link? I’m going for something like this (which obviously doesn’t work)…

$('.itembox').click(function(){
    if ($(this).not('a')) {
        window.location.href = $('a:first',this).attr('href');
    }
});
  • 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-26T15:50:03+00:00Added an answer on May 26, 2026 at 3:50 pm

    You could use jQuery’s stopPropagation method, so that when a user clicks the real link, the click event doesn’t reach the div.

    Something like :

    $('.itembox').click(function(){
        window.location.href = $('a:first',this).attr('href');
    });
    
    $('.itembox').find('a').click(function(e){
        e.stopPropagation();
    })
    

    That being said, if you’re using an HTML5 Doctype, you could simply wrap you’re whole “item” inside an <a> tag. No more need for javascript in this case. See reference here : http://html5doctor.com/block-level-links-in-html-5/

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

Sidebar

Related Questions

Could someone please help me with this scenario, [Some text] [Some text] Device ID:
How do you avoid duplicate bound items in this scenario: There's a databound control
So imagine this scenario: 10.00: your app pushes a message Hello 10.01: your app
need your advices on this scenario: I have a bunch of services installed on
This scenario comes up often, now that I use LinkToSql and the classes it
Consider this scenario: I've an XML file called person.xml with the following data in
Consider this scenario. I have my own website, that I use as my identifier,
Consider this scenario. I have an object, lets call it.... Foo. Foo raises a
Is this scenario even possible? class Base { int someBaseMemer; }; template<class T> class
Imagine this scenario: You have a desktop and a laptop. The desktop has a

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.