[removed] Multiple GetElementByID's in one call

前端 未结 4 858
我在风中等你
我在风中等你 2020-12-20 06:58

Really simple question. I have the following code, and would like to consolidate it down as much as possible. Can\'t get it to work though.. tried using commas etc. Is there

4条回答
  •  时光取名叫无心
    2020-12-20 07:44

    $("#set50").live("click", function() {
        $("statusBox50").addClass("statusBoxSelected");
        $("statusBox25").addClass"statusBox");
        $("statusBox75").addClass( "statusBox");
        $("statusBox100").addClass( "statusBox");
        $(".statusbar").animate({
            width: '115px'
        }, 500);    
    });
    

    is this what u want ?

    .addClass adds a class to the selected element.[docs]

    EDIT: As u said u want a single. Just assign a class to all the elements u want to add the class. For eg: i assign the class adding. then u can addclass to all the elements like this :

    $('.adding').addClass('statusBox')
    

提交回复
热议问题