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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T12:06:10+00:00 2026-05-29T12:06:10+00:00

I have 2 jquery scripts and I’m not sure exactly how to combine them.

  • 0

I have 2 jquery scripts and I’m not sure exactly how to combine them.

Script #1: There is a link inside a DIV, make entire DIV clickable link.

Script #2: Open modal window from a link (standard jQuery UI modal).

Below is the HTML:

<div class="singlefeatureditem">
<a href="product.php?id=123" class="opennewwindow">
<img src="products/thumb_placeholder.jpg" width="125" height="125" alt="thumb"><br>
Item 1</a>
</div>

Below is the JS:

//make the whole div clickable
$(document).ready(function() {
    $(".singlefeatureditem").click(function(){
     window.location=$(this).find("a").attr("href");
     return false;
    });
});

//open the link in a modal window
    $(function (){
        $('a.opennewwindow').click(function() {
            var url = this.href;
            // show a spinner or something via css
            var dialog = $('<div style="display:none" class="loading"></div>').appendTo('body');
            // open the dialog
            dialog.dialog({
                // add a close listener to prevent adding multiple divs to the document
                close: function(event, ui) {
                    // remove div with all data and events
                    dialog.remove();
                },
                modal: true
            });
            // load remote content
            dialog.load(
                url, 
                {}, // omit this param object to issue a GET request instead a POST request, otherwise you may provide post parameters within the object
                function (responseText, textStatus, XMLHttpRequest) {
                    // remove the loading class
                    dialog.removeClass('loading');
                }
            );
            //prevent the browser to follow the link
            return false;
        });
    });

The result I’m currently getting (which I guess is expected) is that if I click the link I get the modal, if I click the DIV (outside the link) the link works but it just opens the page with no modal.

I’d like to make the whole DIV a link and open the modal regardless of where in the DIV is clicked.

Any thoughts?
Thanks!
Chris

  • 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-29T12:06:11+00:00Added an answer on May 29, 2026 at 12:06 pm

    The onclick event of your link is not triggered when you use window.location. Try simulating a click, like this:

    //make the whole div clickable
    $(document).ready(function() {
        $(".singlefeatureditem").click(function(){
         $(this).find("a").click(); /// << "simulate" a click
         return false;
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jQuery script: $.ajax({ url: /scripts/secure/development/ajax.asp, type: POST, dataType: text, data: cmd=addresses,
I have two scripts running on the same page, one is the jQuery.hSlides.js script
I have this jquery script which suppose to hide/show div element base on the
i have the following Jquery function inside my view:- <script type=text/javascript> $(document).ready(function () {
I have this code in the View: <script src=../../Scripts/jquery.form.js type=text/javascript></script> <script src=../../Scripts/jquery-1.5.1.js type=text/javascript></script> <script
My jquery scripts have some php in them to initiate variables, etc. I'm trying
I have a form with a client side validationsummary. View: <script src=@Url.Content(~/Scripts/jquery.validate.min.js) type=text/javascript></script> <script
I have the following code in my ASP.NET MVC 3 project: <script src=@Url.Content(~/Scripts/jquery.validate.min.js) type=text/javascript></script>
i have been trying to make 2 scripts(1 mootol and 1 jquery) work at
I have an Asp.net MVC project that modestly uses jQuery scripts. My views also

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.