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

Auto Save

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 lang="ja">
<head>
    <meta charset="UTF-8">
    <title>回文確認</title>
    <style type="text/css">
        body{ 
            background-color:#f0f8ff;
            color : #000000;
            margin-right: auto;
            margin-left : auto;
            width:700px;
            font-size:200%;
            font-weight: 900;
        }
    </style>
</head>
<body>
    <h1>回文確認</h1>
    <div>確認したい文字を入力してください</div>
    <input style="width: 75%;" type="text" id="check" placeholder="確認したい文字列">
    <input type="button" onClick="check()" value="確認する">
    <div>(入力した文字)</div>
    <span id='check_word''></span>

    <div>(反対にした文字)</div>
    <span style="color:red;" id='complete'></span>
    <br><br>
    <div id='check_result'></div>
</body>
<script type="text/javascript">
    function check(){
        var word = document.getElementById("check").value;

        if(word != ''){
            //入力した文字を表示
            document.getElementById('check_word').innerHTML = word;

            //入力された文字列を反対にする処理
            const converted = [];    // 文字を格納する配列を用意する。
            for (let i = 0, len = word.length; i < len; i++) {
            const char = word.charAt(i);    // インデックスの位置の一文字を取得する。
            converted.push(char);           //  要素を追加する。
            }
            let reversed = '';    // 反転された文字を入れる変数を用意する。
            for (let i = 0, len = converted.length; i < len; i++) {
            const popped = converted.pop();    // 配列の末尾から1つ取り出す。
            reversed += popped;                // 文字を繋げる。
            }

            //反対にした文字を表示
            document.getElementById('complete').innerHTML = reversed;

            //入力文字と反対文字が一致しているか確認して表示
            if(word == reversed){
                var check_result = '回文です';
            } else {
                var check_result = '回文ではないです';
            }
            document.getElementById('check_result').innerHTML = check_result;
        }
    }
</script>
</html>
              
            
!

CSS

              
                
              
            
!

JS

              
                
              
            
!
999px

Console