“无法读取未定义的属性..."在jQuery 1.11.0中-如何满足jQuery的要求? [英] "Cannot read property ... of undefined" in jQuery 1.11.0 -- how can I satisfy jQuery's requirement?

查看:85
本文介绍了“无法读取未定义的属性..."在jQuery 1.11.0中-如何满足jQuery的要求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在(尝试)从CDN中最小化加载jQuery 1.9.1:未捕获的TypeError:无法调用未定义的jquery-1.9.1.js:648的方法'call'".因此,我更新了参考文献,显然得到了一个等效的错误,现在缩小了:

I was (trying to) load jQuery 1.9.1 un-minified from CDN: "Uncaught TypeError: Cannot call method 'call' of undefined jquery-1.9.1.js:648". So I updated the reference, and am apparently getting an equivalent error, now for minified:

Uncaught TypeError: Cannot call method 'call' of undefined jquery-1.11.0.min.js:2
n.extend.each jquery-1.11.0.min.js:2
(anonymous function) site.js:26
j jquery-1.11.0.min.js:2
k.fireWith jquery-1.11.0.min.js:2
n.extend.ready jquery-1.11.0.min.js:2
K jquery-1.11.0.min.js:2

该页面位于 http://ccachicago.pragmatometer.com ;第一个SCRIPT标签是:

The page is at http://ccachicago.pragmatometer.com; the first SCRIPT tag is:

<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>

(该页面为POSH加CSS样式,并带有少量JavaScript灰尘;按现代的webapp标准,这很简单...)

(The page is POSH plus CSS styling and a light touch of JavaScript dust; it's simple by modern webapp standards...)

-编辑-

关于我的代码,该页面具有唯一的脚本内容:

Regarding my code, the page has, as its only script contents:

    <script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
    <script src="/media/js/site.js"></script>

        <script>
                        function slideshow()
            {
            var width = (jQuery(window).width()  - 70) * .8;
            var factor = width / 1024;
            var height = 420 * factor;
            jQuery('#slideshow').attr('height', height + 'px');
            jQuery('#slideshow').attr('width', width + 'px');
            };
        slideshow();
        jQuery(window).resize(slideshow);
        </script>

site.js文件具有:

The site.js file has:


/**
 * Override jQuery.fn.init to guard against XSS attacks.
 *
 * See http://bugs.jquery.com/ticket/9521
 */
(function () {
  var jquery_init = jQuery.fn.init;
  jQuery.fn.init = function (selector, context, rootjQuery) {
    // If the string contains a "#" before a "= 0) {
        var bracket_position = selector.indexOf(' hash_position) {
          throw 'Syntax error, unrecognized expression: ' + selector;
        }
      }
    }
    return jquery_init.call(this, selector, context, rootjQuery);
  };
  jQuery.fn.init.prototype = jquery_init.prototype;
})();

jQuery(function()
    {
    jQuery.each(jQuery('h1').add('h2').add('h3').add('h4').add('h5').add('h6').add('ul#navigation')).function(index, element)
        {
        var bounds = jQuery(element).offset();
        var image_left = bounds.left;
        var image_top = bounds.top + bounds.height;
        var image = jQuery('');
        image.style.position = 'absolute';
        image.style.top = image_top + 'px';
        image.style.left = image_left + 'px';
        }
   function set_search_width()
        {
        var offset = 950;
        var width = jQuery(window).width() - offset;
        jQuery('#menu-search').css('max-width', width + 'px');
        jQuery('#menu-search').css('width', width + 'px');
        jQuery('#query').width(width - 80);
        }
    jQuery(window).resize(set_search_width);
    set_search_width();
    });
sfHover = function()
    {
    var sfEls =
    document.getElementById('nav').getElementsByTagName('li');
    for(var index = 0; index 

/**
 * Override jQuery.fn.init to guard against XSS attacks.
 *
 * See http://bugs.jquery.com/ticket/9521
 */
(function () {
  var jquery_init = jQuery.fn.init;
  jQuery.fn.init = function (selector, context, rootjQuery) {
    // If the string contains a "#" before a "<", treat it as invalid HTML.
    if (selector && typeof selector === 'string') {
      var hash_position = selector.indexOf('#');
      if (hash_position >= 0) {
        var bracket_position = selector.indexOf('<');
        if (bracket_position > hash_position) {
          throw 'Syntax error, unrecognized expression: ' + selector;
        }
      }
    }
    return jquery_init.call(this, selector, context, rootjQuery);
  };
  jQuery.fn.init.prototype = jquery_init.prototype;
})();

jQuery(function()
    {
    jQuery.each(jQuery('h1').add('h2').add('h3').add('h4').add('h5').add('h6').add('ul#navigation')).function(index, element)
        {
        var bounds = jQuery(element).offset();
        var image_left = bounds.left;
        var image_top = bounds.top + bounds.height;
        var image = jQuery('<img src="/media/images/foldback.png">');
        image.style.position = 'absolute';
        image.style.top = image_top + 'px';
        image.style.left = image_left + 'px';
        }
   function set_search_width()
        {
        var offset = 950;
        var width = jQuery(window).width() - offset;
        jQuery('#menu-search').css('max-width', width + 'px');
        jQuery('#menu-search').css('width', width + 'px');
        jQuery('#query').width(width - 80);
        }
    jQuery(window).resize(set_search_width);
    set_search_width();
    });
sfHover = function()
    {
    var sfEls =
    document.getElementById('nav').getElementsByTagName('li');
    for(var index = 0; index < sfEls.length; index++)
        {
        sfEls[i].onmouseover = function()
            {
            this.className += " sfhover";
            }
        sfEls[i].onmouseout = function()
            {
            this.className = this.className.replace(new RegExp(
              " sfhover\\b"), "");
            }
        }
    }
if (window.attachEvent)
    {
    window.attachEvent("onload", sfHover);
    }

推荐答案

语法不正确

您想做什么?

jQuery(function()
    {
    jQuery.each(jQuery('h1').add('h2').add('h3').add('h4').add('h5').add('h6').add('ul#navigation')).function(index, element)
        {
        var bounds = jQuery(element).offset();
        var image_left = bounds.left;
        var image_top = bounds.top + bounds.height;
        var image = jQuery('<img src="/media/images/foldback.png">');
        image.style.position = 'absolute';
        image.style.top = image_top + 'px';
        image.style.left = image_left + 'px';
        }
   function set_search_width()
        {
        var offset = 950;
        var width = jQuery(window).width() - offset;
        jQuery('#menu-search').css('max-width', width + 'px');
        jQuery('#menu-search').css('width', width + 'px');
        jQuery('#query').width(width - 80);
        }
    jQuery(window).resize(set_search_width);
    set_search_width();
    });

也许下面的代码是您想要的? (找到元素,我认为最好使用复杂的选择器,并将函数应用于每个元素)

maybe code below is what you want ? ( find elements, i think it is better use complex selector, and apply function to each element )

jQuery('h1').add('h2').add('h3').add('h4').add('h5').add('h6').add('ul#navigation').each(function(index, element)
    {
    var bounds = jQuery(element).offset();
    var image_left = bounds.left;
    var image_top = bounds.top + bounds.height;
    var image = jQuery('<img src="/media/images/foldback.png">');
    image.style.position = 'absolute';
    image.style.top = image_top + 'px';
    image.style.left = image_left + 'px';
    });

这篇关于“无法读取未定义的属性..."在jQuery 1.11.0中-如何满足jQuery的要求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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