How to set multiple CSS display property values with jquery

后端 未结 3 651
温柔的废话
温柔的废话 2021-01-25 00:54

Ok, this is driving me a bit batty. I am using the jQuery .css() method to try to set the multiple flexbox display properties needed for a class. Problem is, it only ke

3条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-25 01:44

    Store it in a variable:

    var displayStyle = [
      'display: -webkit-box',
      'display: -webkit-flex',
      'display: -moz-box',
      'display: -ms-flexbox',
      'display: flex'
    ].join(';');
    
    
    $(document).ready(function() {
      $(".department-name").attr('style', displayStyle);
    });
    
    
    TEST

提交回复
热议问题