1

I'm attempting to wrap all of my table elements in the class .table-container but only if the class isn't already applied. This is the function that is working properly to add the styling:

attach: function (context, settings) {
    ("table").wrap("<div class='table-container'></div>")
}

What other jQuery needs to be applied to tell the function not to wrap the table element if the class is already being applied? (A third party manually wrapped some of the tables so I don't want to apply unnecessary CSS).

droobey
  • 9
  • 3

1 Answers1

1

You should be able to do something like this

if(!$("table").hasClass("table-container")){
    $("table").wrap("<div class='table-container'></div>");
 }

See this post

Yaakov David
  • 133
  • 8