jQuery width() method performance

后端 未结 3 773
一个人的身影
一个人的身影 2020-12-21 17:09

I\'m a jQuery noob trying to track down a performance issue that we\'re having with large tables. We have a homegrown table widget which, among other things, sets the colum

3条回答
  •  青春惊慌失措
    2020-12-21 17:35

    Use .css("width") instead of .width(), changes were made to the .width() method that make it perform slower. Read this for more information: http://blog.jquery.com/2012/08/16/jquery-1-8-box-sizing-width-csswidth-and-outerwidth/

    var commonWidth = Math.max(
      Math.min(parseFloat(headerTd.css("width")), 100),
      dataTd.width()
    );
    

提交回复
热议问题