[removed] Multiple GetElementByID's in one call

前端 未结 4 861
我在风中等你
我在风中等你 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条回答
  •  Happy的楠姐
    2020-12-20 07:25

    Is there a way to call more than one ID in the GetElementByID method?

    No, and it is Id (with a lower case d)

    And don't use setAttribute, it is broken in all but the most recent versions of IE.

    You're using jQuery, so you can use its helper functions:

    jQuery('#statusBox50').addClass('statusBoxSelected');
    jQuery('#statusBox25, #statusBox75, #statusBox100').addClass('statusBox');
    

提交回复
热议问题