调整屏幕大小后重命名函数

Rename a function after resizing screen

本文关键字:重命名 函数 屏幕 调整      更新时间:2023-09-26
调整

屏幕大小后是否可以更改函数的名称?

我有这个

<div id="box1" data-same-height="blocks-resize">

哪里

data-same-height="blocks-resize"

是函数,这是该函数的 JavaScript。

$(document).ready(function() {
var equalize = function () {
    var disableOnMaxWidth = 0; // 767 for bootstrap
    var grouped = {};
    var elements = $('*[data-same-height]');
    elements.each(function () {
        var el = $(this);
        var id = el.attr('data-same-height');
        if (!grouped[id]) {
            grouped[id] = [];
        }
        grouped[id].push(el);
    });
    $.each(grouped, function (key) {
        var elements = $('*[data-same-height="' + key + '"]');
        elements.css('height', '');
        var winWidth = $(window).width();
        if (winWidth <= disableOnMaxWidth) {
            return;
        }
        var maxHeight = 0;
        elements.each(function () {
            var eleq = $(this);
            maxHeight = Math.max(eleq.height(), maxHeight);
        });
        elements.css('height', maxHeight + "px");
    });
};
var timeout = null;
$(window).resize(function () {
    if (timeout) {
        clearTimeout(timeout);
        timeout = null;
    }
    timeout = setTimeout(equalize, 250);
});
equalize();

});

屏幕大小调整为 600px 后是否可以更改该名称(数据相同高度)? 或者也可以是"块调整大小"

谢谢!

       $(function(){
          $(window).on("resize load", responsive);
       }) 
       var responsive = function() {
          if(window.innerWidth < 600) {
             //do your thing
          } else {
            //do something else.
         }
       }