Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

              
                <!DOCTYPE html>
<html>
    <head>
        <link href="https://fonts.googleapis.com/css2?family=Roboto&display=swap" rel="stylesheet"> 
        <link href="styles.css" type="text/css" rel="stylesheet" />
        <meta charset="utf-8">
        <title>jQuery Selectors Testing</title>
    </head>
    <body>
        <header>jQuery Selector Testing</header>
        <section id="section1" class="testClass">
            Boop dee-wop bobaadop-dop doop!
        </section>
        <section id="section2" class="testClass">
            Baa-badAP-DAP-dooooo-WAP!
        </section>
        <section id="section3" class="testClass">
            Wee-bee-ba-dop! Doop dee-wop!
        </section>
        <button id="idButton">jQuery ID method</button>
        <button id="classButton">jQuery Class method</button>
        <button onclick="changeClass()">JavaScript class method</button>
        <button onclick="changeId()">JavaScript ID method</button>
    </body>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> 

    <script>

        // jQuery ID selector: pick a thing, do a thing.
        $('#idButton').click(function() {
            $('#section1').css('color', 'blue');
        });

        //jQuery class selector. Pick multiple things, do one thing all at once. PRETTY COOL.
        $('#classButton').click(function() {
            $('.testClass').css('color', 'red');
        });

        // JavaScript Class selector. Pick a class name, save it to something, loop over that something, and do things.
        function changeClass() {
            let coolClasses = document.getElementsByClassName('testClass');
            for (let i = 0; i < coolClasses.length; i++) {
                coolClasses[i].style.color = 'green';
            }
        }

        // JavaScript ID selector. Pick an ID, do a thing. If you use the same ID more than once; first, re-evelaute your decisions; second, watch only the first thing change.
        function changeId() {
            let coolID = document.getElementById('section2').style.color = 'purple';
        }

    </script>


</html>
              
            
!

CSS

              
                header {
    font-size: 22px;
    margin-bottom: 1vw;
}

* {
    font-family: roboto, arial, sans-serif;
}

section {
    line-height: 2vw;
}

#testButton {
    margin-top: 2vw;
}
              
            
!

JS

              
                
              
            
!
999px

Console