How to create Hash object/array using jquery?

前端 未结 5 1075
挽巷
挽巷 2021-01-05 18:55

I know there is a Hash() object in the Javascript prototype framework, but is there anything in Jquery like this?

As I would like to stick with one javascript framew

5条回答
  •  清酒与你
    2021-01-05 19:36

    There is no prototype Hash equivalent in jQuery that I know of.

    Could the following be of any use to you? using jQuery

    var starSaves = {};
    
    function myHover(id,pos)
    {
        var starStrip = $('.star_strip_' + id);
        if(!starSaves[id])
        {
            var starSave = [];
            starStrip.each(function(index,element){
                starSave[index] = $(element).attr('src');
                $(element).attr('src', index < pos ? '/images/star_1.gif' : '/images/star_0.gif');
            });
            starSaves[id] = starSave;
        }
    }
    

提交回复
热议问题