Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <h4>.toggleClass(className)和.toggleClass(className,switch)</h4>
<table id="table" width="50%" border="0" cellpadding="3" cellspacing="1">
  <tr>
    <td>慕课jQuery入门</td>
    <td>慕课jQuery入门</td>
  </tr>
  <tr>
    <td>慕课jQuery入门</td>
    <td>慕课jQuery入门</td>
  </tr>
  <tr>
    <td>慕课jQuery入门</td>
    <td>慕课jQuery入门</td>
  </tr>
  <tr>
    <td>慕课jQuery入门</td>
    <td>慕课jQuery入门</td>
  </tr>
  <tr>
    <td>慕课jQuery入门</td>
    <td>慕课jQuery入门</td>
  </tr>
</table>
              
            
!

CSS

              
                body,
table,
td {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 12px;
}

.h {
  background: #f3f3f3;
  color: #000;
}

.c {
  background: #ebebeb;
  color: #000;
}

              
            
!

JS

              
                //给所有的tr元素加一个class="c"的样式
$("#table tr").toggleClass("c");
//给所有的偶数tr元素切换class="c"的样式
//所有基数的样式保留,偶数的被删除
$("#table tr:odd").toggleClass("c");
//第二个参数判断样式类是否应该被添加或删除
//true,那么这个样式类将被添加;
//false,那么这个样式类将被移除
//所有的奇数tr元素,应该都保留class="c"样式
$("#table tr:even").toggleClass("c", true); //这个操作没有变化,因为样式已经是存在的

              
            
!
999px

Console