I have the following code which processes a click from a tab and loads contents via ajax:
$(document).ready(function()
{
$("#tab1").click(function()
{
loadTab($(this).attr("href") + "?ajax=1");
return false; // cancel the event
});
$("#tab2").click(function()
{
loadTab($(this).attr("href") + "?ajax=1");
return false; // cancel the event
});
$("#tab3").click(function()
{
loadTab($(this).attr("href") + "?ajax=1");
return false; // cancel the event
});
$("#tab4").click(function()
{
loadTab($(this).attr("href") + "?ajax=1");
return false; // cancel the event
});
});
You'll notice that there are lots of repeated code.
Is there any way of grouping the #tab1, #tab2, .... into a single .click(function() ?