treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Attaching a target propety to certain links

  • 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?
  • $(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.
  • My thanks! That goes in the snippets folder!