Grow your CSS skills. Land your dream job.

jquery click function

  • # January 31, 2012 at 11:59 am

    I have this:

    $('#slidecaption, #slidecaption-grande').click(function() { //some code here...

    What I want to make is to open an external link like “www.google.com” after this function is clicked.
    How can I make this ?

    # January 31, 2012 at 12:23 pm
    $('#slidecaption, #slidecaption-grande').click(function(){
    window.open($(this).attr('rel'));
    });

    this would open a new window with the location of whatever is in the ‘rel’ attribute

    http://css-tricks.com/snippets/jquery/open-external-links-in-new-window/

    # January 31, 2012 at 12:43 pm

    Thanks, but I want to add the link directly in the .click function.
    Is it possible ?

    # January 31, 2012 at 3:22 pm

    are you clicking on the div itself? or an anchor?

    # January 31, 2012 at 3:25 pm

    On a div. The idea is that I want to put the link in the javascript function not in the html markup.

    # January 31, 2012 at 3:34 pm
    window.open('http://website.com');
    # January 31, 2012 at 7:05 pm

    Thank you!

    # January 31, 2012 at 9:03 pm

    Any time :)

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".