Grow your CSS skills. Land your dream job.

Attaching a target propety to certain links

  • # April 15, 2010 at 4:37 pm

    Hey guys an gals,

    I’m pulling in an rss feed from a FaceBook Notes app via WP’s RSS widget, and it’s all hunky-dory, except that I want the resulting links to have a ‘target="_blank"’ property. WordPress is giving those links a class, which I can work away with for styling via CSS, but is there a way (I’m thinking JQuery) of attaching properties too?

    # April 15, 2010 at 5:53 pm
    Code:
    $(document).ready(function(){
    $(“a.example[href^='http']“).click(function(){
    window.open(this.href);
    return false;
    });
    });

    This will open any <a> link, that has a class of "example" and begins with "http", in a new window.

    # April 16, 2010 at 8:41 pm

    My thanks! That goes in the snippets folder!

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

You must be logged in to reply to this topic.

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