php - Wildcard a href id with jquery? -


i have series of links so:

<a href="http://www.google.com" id="link01">google</a> <a href="http://www.yahoo.com" id="link02">yahoo</a> <a href="http://www.cnn.com" id="link03">cnn</a> <a href="http://www.facebook.com" id="link04">facebook</a> 

is possible jquery have execute function if id of linkxx clicked , shuttle on link target? links variable in number, target , id name, unifying feature id have words 'link' followed 2 numbers.

thanks!!!

you can use starts selector select elements have id starts "link"

$('a[id^="link"]').click(function(e){   // actions }); 

example: http://jsfiddle.net/niklasvh/jjsrf/


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -