var $this = $(this); if ($this.is('#bbutton_1')) var a='a1'; else if ($this.is('#bbutton_2')) var a='a2'; ...