I have a script and I need to specify some of my anonymous click functions. For example, here is some code:
The document is ready:
$(function(){
$('#map').imagemap([
{top_x: 1,top_y: 2,bottom_x: 290,bottom_y:380,callback:
{top_x: 275,top_y: 2,bottom_x: 470,bottom_y:380,callback:
{top_x: 460,top_y: 2,bottom_x: 701,bottom_y:380,callback:
]);
$('#id1').click(function() {
....
});
$('#id2').click(function() {
....
});
$('#id3').click(function() {
....
});
...
});
How do I write my callbacks so as not to duplicate the code outside document.ready
? I tried to put everything in a row following callback:
, but it did not work. So what do I put in place of anonymous function callbacks?
source
share