function canBe(el) { $('#canbe').html(array[el.attr('id')]); }
<!DOCTYPE HTML> <html> <head> <title>Untitled</title> <meta charset="utf-8"> <style type="text/css"> </style> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <script> $(function() { var array = { 2015: "всякая фигня" }; function canBe(el) { $("#canbe").html(array[el.attr("id")]) } canBe($(".test")) }); </script> </head> <body> <span id="canbe"></span> <span id="2015" class="test"></span> </body> </html>