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

  • Home
  • SEARCH
  • 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 3852904
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:23:15+00:00 2026-05-19T17:23:15+00:00

Easy enough to make a div with a background image clickable: $(.socialMedia).click(function(){ window.location=$(this).find(a).attr(href); return

  • 0

Easy enough to make a div with a background image clickable:

$(".socialMedia").click(function(){
             window.location=$(this).find("a").attr("href");
             return false;
        });

How can you make that open in a new window, its not using the anchor’s target element, when I switch window.location to window.open i get an error. Is it possible?
thx

  • 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-19T17:23:15+00:00Added an answer on May 19, 2026 at 5:23 pm
    $('.socialMedia').click(function(e){
      e.preventDefault();
      window.open($(this).find('a:first').attr('href'), '');
    });
    

    In this bit of JavaScript we are selecting all elements that have the socialMedia class. We then bind a callback function to each of these elements. This function defines one parameter, e, that represents the jQuery Event object.

    Now, when a user clicks one of the socialMeda elements our callback function executes. First, the function uses the jQuery event.preventDefault() method to stop the browser from performing any default actions (e.g. go to a URL defined in a clicked link element). Then we use the window.open() method to open our desired URL. We get this URL by finding the first link element within the socialMedia element that was clicked (just in case there are multiple links).

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

Sidebar

Related Questions

It's easy enough to set up a table view to allow editing. Just add
When using one's own iPhone for development it's easy enough to access any crash
We have various servers that have many directories shared. It's easy enough to look
Speed and learnability do not directly fight each other, but it seems easy enough
My experience with MySQL is very basic. The simple stuff is easy enough, but
Easy question this time. I'm trying to test whether or not a string does
Another easy one hopefully. Let's say I have a collection like this: List<DateTime> allDates;
Is there an easy way to iterate over an associative array of this structure
An easy jQuery question. I have several identical forms ( except their name )
Is there an easy way in C# to create Ordinals for a number? For

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.