jQuery Dynamically add an icon for external links


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. $(document).ready(function() {
  2. $('#extlinks a').filter(function() {
  3. return this.hostname && this.hostname !== location.hostname;
  4. }).after(' <img src="/images/external.png" alt="external link"/>');
  5. });

URL: http://www.learningjquery.com/2008/08/quick-tip-dynamically-add-an-icon-for-external-links

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.