looking for some feedback / advice from advanced web devs on how to actually write manageable code for this scenario.
Scenario
We have various links on the site in containers. Upon clicking one of these, we use jQuery to create an iframe and load a page in it.
HTML part: (starting after body)
<a id="slot1" href="#0">Text</a>
<a id="slot2" href="#0">Text</a>
<a id="slot3" href="#0">Text</a>
<a id="slot4" href="#0">Text</a>
<!-- iframe content will be displayed within this div -->
<div id="content">
</div>
jQuery:
<script>
$("#slot1").click(function(){$("#content").html('<iframe src="http://www.google.de/">');});
$("#slot2").click(function(){$("#content").html('<iframe src="http://www.google.com/">');});
$("#slot3").click(function(){$("#content").html('<iframe src="http://www.google.co.uk/">');});
$("#slot4").click(function(){$("#content").html('<iframe src="http://www.google.ru/">');});
</script>
Now this gets tedious and redundant if the list grows (think of #slot57 !). How to write it more flexible and elegant?
So far I thought of targeting all slot IDs $('[id^="slot"]') and slicing the index(4) in order to get the actual clicked number. But then how to load the right iframe content!?
I'm stuck. Any thoughts / advice?