Issue with onClick() and middle button on mouse

后端 未结 3 519
执笔经年
执笔经年 2020-12-20 23:42
\" onClick=\"countLinks(\'\',\'\')\">[Link ]

The pr

3条回答
  •  旧巷少年郎
    2020-12-21 00:09

    Here is a quick solution for you, by using some html5 attributes... Actually it was also possible before html5 but it wasn't validating.

    I'd create the links as below:

    ...

    _here we put your parameters to data attributes

    and write the js like this:

    $(function(){
        //use mouseup, then it doesn't matter which button 
        //is clicked it will just fire the function
        $('.myClazzz').bind('mouseup', function(e){
            //get your params from data attributes
            var row   = $(this).attr("data-row"),
                index = $(this).attr("data-index");
    
            //and fire the function upon click
            countLinks(row,index);
        });
    });
    //don't forget to include jquery, before these lines;)
    

    Hope this works out. Sinan.

    PS myClazzz -> credits goes to jAndy :)

提交回复
热议问题