jQuery自定义函数在母版页上不起作用 [英] jQuery custom function not working on master page

查看:61
本文介绍了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.

推荐答案

(文档).ready(
(document).ready(function () {


(# btnTest').click(函数(){ 尝试 {
('#btnTest').click(function () { try {


.myCustomMethod(' ' popup.aspx' 600 400 ); } 捕获(e){ 警报(e); } }); });
.myCustomMethod('testing title!', 'popup.aspx', 600, 400); } catch (e) { alert(e); } }); });


我的js代码是


my js code is

(function (


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆