add class to <a> if href starts with http://www.twitter.com/ [duplicate]
Possible Duplicate:
jQuery: Select <a> which href contains some string
I am working on a little twitter implementation for a website. The javascript I use exports the code as following:
<ul>
<li>twitter message here <a href="http://twitter.com/username/ID">time of twitter</a></li>
<开发者_Python百科;/ul>
Now I like to add a class to the twitter link, so I can give it a different css then normal links inside the tweets.
Anyone got any thoughts how to fix this in a proper way? :)
$('a[href^="http://twitter.com"]').addClass('twitter');
http://jsfiddle.net/apjD6/
$(function() {
$("a[href^='http://twitter.com/']").addClass("someClass");
});
Check reference here:
http://api.jquery.com/attribute-starts-with-selector/
精彩评论