找到你要的答案

Q:Replacing .Click() Function in Jquery with some other name [closed]

Q:更换。与其他一些名称[ jQuery()函数关闭]

I want to replace .click() function by some other name for example .xyz() how do I write a function for it.

I want to replace .click() function by some other name for example .xyz() how do I write a function for it.

answer1: 回答1:

You can try jQuery $.extend method.

For Ex:

 $.extend($.fn, {
        xyz: function (method, data) {
//do whatever 
}});

你可以试试jQuery扩展方法。

为前:

 $.extend($.fn, {
        xyz: function (method, data) {
//do whatever 
}});
answer2: 回答2:

It kind of depends on your purpose; if you want to simply have a function called every time a .click() happens, you can use $('#id').bind('click', function() { /* do something */ }). Returning false at the end of the scope of the bound function, stops events from propagating.

它取决于你的目的;如果你想只是一个函数调用一次。()发生的时候,你可以使用$(' # ID)。绑定(听到咔哒声,function() { /* */ }做某事)。在绑定函数的作用域返回false,停止事件的传播。

answer3: 回答3:

You can refer the detailed documentation here http://api.jquery.com/jquery.extend/

And do it this way,

$.extend($.fn, {
        yourFunctionName : function (method, data) {
            // your code
        }
});

你可以参考这里的详细文档http://api.jquery.com/jquery.extend/

这样做,

$.extend($.fn, {
        yourFunctionName : function (method, data) {
            // your code
        }
});
jquery