Very short snippet: jQuery auto target blank link

Nothing new, but the sign to remind me: how to add an image to all the links that open a new page:

1
) . addClass ( 'external' ) ; jQuery ('a [@ target = _blank]'). addClass ('external');

The CSS class extenal looks like this:

1
background : url ( images/external.png ) no-repeat right 3px ; padding-right : 14px } . External {background: url (images / external.png) no-repeat right 3px; padding-right: 14px}

As an image you can use: external

The result is miolink

3 comments to "Very short snippet: jQuery auto target blank link"

  1. January 24, 2009 Adding an image to all the links that open a new page | Simone D'Amico :

    [...] | Undolog posted under jQuery, Javascript Related Posts: CSS and jQuery: Select a row in a [...]

  2. January 25, 2009 Giovambattista Fazioli :

    With jQuery 1.3 (or higher) is necessary to eliminate the (t, @) from the code, which becomes:

    1
    ) . addClass ( 'external' ) ; jQuery ('a [target = _blank]'). addClass ('external');
  3. February 2, 2009 Gustavo Macedo :

    post in Italian ...
    Perfect, thanks for the lines. As soon as possible to implement in my css
    And to live on usability!

Leave a comment

XHTML TAG PERMIT: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> INSERTION CODE:
 <pre></pre> // blocco generico <code></code> // blocco generico [cc_actionscript][/cc_actionscript] // Actionscript [cc_actionscript3][/cc_actionscript3] // Actionscript 3 [cc_css][/cc_css] // CSS Style Sheet [cc_html][/cc_html] // HTML [cc_js][/cc_js] // Javascript [cc_objc][/cc_objc] // Objective-C [cc_php][/cc_objc] // PHP [cc_sql][/cc_sql] // SQL 


Stop SOPA