[Solved] “Cannot read property … of undefined” in jQuery 1.11.0 — how can I satisfy jQuery’s requirement?


You have incorrect syntxis

What do you whant to do with ?

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="https://stackoverflow.com/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="https://stackoverflow.com/media/images/foldback.png">');
    image.style.position = 'absolute';
    image.style.top = image_top + 'px';
    image.style.left = image_left + 'px';
    });

solved “Cannot read property … of undefined” in jQuery 1.11.0 — how can I satisfy jQuery’s requirement?