javascript - Trouble with returning a correct element ID -


i've got 3 links serve sorting headings table, each member of "sort" class. wrote simple jquery function gets triggered when "sort" class link clicked. there's switch case assigns column number (columnnum) used tablesorter plugin. however, right i'm getting weird values returned id of sort classes.

$(".sort").toggle(function() {      // column id's datecaption, hourscaption, taskcaption     var column = $(this).attr('id');     var columnnum;      switch(column){         case 'datecaption':             columnnum = 1;             break;         case 'hourscaption':             columnnum = 2;             break;         case 'taskcaption':             columnnum = 3;             break;         default:             break;     }      var sorting = [[columnnum,1]];      $("#task_table").trigger("sorton",[sorting]);      return false;  }, function(){     var sorting = [[columnnum,0]];      $("#task_table").trigger("sorton",[sorting]);      return false;                });   

if alert column variable, "aeaoofnhgocdbnbeljkmbjdmhbcokfdb-mousedown"--which doesn't serve rest of function well.

can tell me why might happening?

thanks

without more code or html it's hard say. guess $(this) isn't think is. try adding console.log($(this)); (preferably in firebug) click result , see $(this) referring to.

additionally, query dom $('#aeaoofnhgocdbnbeljkmbjdmhbcokfdb-mousedown') , see , should element $(this) referring to.

for more information on "this" refer in different situations, check out mozilla developer network: https://developer.mozilla.org/en/javascript/reference/operators/this


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -