syntax error

<a href="#" class="button buttona">A</a>
<a href="#" class="button buttonb">A</a>

on page load function

var obj = $(".button");
obj.each(function(i) {
 if(obj.eq(i).hasClass('buttona')) {
  obj.eq(i).click(function() {
    alert(' I am button A ' );
  });
 }
});

On Fri, Nov 6, 2009 at 11:40 AM, waseem sabjee <waseemsab...@gmail.com>wrote:

> markup
>
> <a href="#" class="button buttona">A</a>
> <a href="#" class="button buttonb">A</a>
>
> on page load function
>
> var obj = $(".button");
> obj.each(function(i) {
>  if(obj.eq(i).hasClass('buttona') {
>   obj.eq(i).click(function() {
>     alert(' I am button A ' );
>   });
>  }
> });
>
>
> does this work better for you ?
>
> On Fri, Nov 6, 2009 at 11:34 AM, aze <az...@oum.edu.my> wrote:
>
>> Thanks for the reply
>>
>> but as you can see I need to do initialize something and then hook the
>> click event. The html markup is like this
>>
>> <a href="#" class="btnA"></a>
>> <a href="#" class="btnB"></a>
>>
>> then after page load, script will execute as follow
>>
>> $(".btnA").btnInit("Button A", function () { do some action 1 });
>> $(".btnB").btnInit("Button B", function () { do some action 2 });
>>
>>
>> different button has different action
>> then , I have this plugin
>>
>> (function($){
>> $.fn.btnInit = function() {
>>  function prepare(obj, caption, action) {
>>    obj
>>        .html(caption)
>>        .addClass("fg-button ui-state-default ui-corner-all")
>>        .click(function(){
>>                  // run the action here when click triggered
>>                   alert('Do some action');});
>>        };
>>
>>
>>        return this.each(function(caption, action){
>>                obj = $(this);
>>                prepare(obj, caption, action);
>>        });
>>
>>
>>
>> };
>> })(jQuery);
>>
>>
>> Thanks
>>
>>
>

Reply via email to