本文介绍了jQuery自定义函数在母版页上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Web应用程序中创建了一个自定义jQuery函数,并且在没有母版页的情况下也可以正常工作,现在我有了母版页,并且在内容页上添加了对我的.js文件的引用,并调用了自定义js方法然后给我类似
的错误

I have created a custom jQuery function in my web application and it is working fine without master pages, now I have a master page and i have added a reference to my .js file on the Content page and call the custom js method then it gives me error like

Type error: object function (selector, context){ //the jquery object is actually just the constructor 'enhanced' return new jQuery.fn.init(selector, context, rootjQuery); }has no method 'myCustomMethod'


我正在调用自定义方法,例如:


i am calling the custom method like:

$(document).ready(function () {
          $('#btnTest').click(function () {
              try {
                  $.myCustomMethod('testing title!', 'popup.aspx', 600, 400);
              } catch (e) {
                  alert(e);
              }
          });
      });


我的js代码是


my js code is

(function ($) {
$.fn.myCustomMethod = function (title, src, width, height) {
 // all my code here }; 
})(jQuery);



任何帮助将不胜感激.



any help would be greatly appreciated.

推荐答案




我的js代码是


my js code is

(function (


这篇关于jQuery自定义函数在母版页上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 18:39
查看更多