HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
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.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
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.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<form action="" method="post">
<div class="check" name="area">
<label><input type="checkbox" value="エリアA"> エリアA</label>
<label><input type="checkbox" value="エリアB"> エリアB</label>
<label><input type="checkbox" value="エリアC"> エリアC</label>
<label><input type="checkbox" value="エリアD"> エリアD</label>
<label><input type="checkbox" value="エリアE"> エリアE</label>
</div>
<div class="check" name="count">
<label><input type="checkbox" value="01"> 01</label>
<label><input type="checkbox" value="02"> 02</label>
<label><input type="checkbox" value="03"> 03</label>
<label><input type="checkbox" value="04"> 04</label>
<label><input type="checkbox" value="05"> 05</label>
</div>
<div class="check" name="other">
<label><input type="checkbox" value="その他1"> その他1</label>
<label><input type="checkbox" value="その他2"> その他2</label>
<label><input type="checkbox" value="その他3"> その他3</label>
<label><input type="checkbox" value="その他4"> その他4</label>
<label><input type="checkbox" value="その他5"> その他5</label>
</div>
<div class="check">
<input type="reset" value="リセットする">
</div>
</form>
<ul>
<li class="area_field">地域:</li>
<li class="count_field">数量:</li>
<li class="other_field">その他:</li>
</ul>
form{
border: 3px #000 solid;
padding: 30px;
width:600px;
background-color: #ffc;
}
.check{
margin-bottom: 30px;
}
$(function(){
//チェック値 取得用変数
var checkVal;
//name属性用変数
var name;
//チェックボックスが変化した際の処理
$(".check input").on("change",function(){
//チェックしたボックスの親要素のname属性取得
name = $(this).parents("div").attr("name");
//チェックボックスの値を取得
checkVal = $(this).val();
//チェックが入った場合
if($(this).is(":checked")){
/*
取得した親要素のname属性を頭に付与したclassをセレクタに指定
取得した値を地域のテキストに表示
(appendで追加 / 複数ある場合を考慮してスペースで区切り)
*/
$("." + name + "_field").append("<span>" + checkVal + " </span>");
}else{//チェックが外れた場合
//チェックボックスの値を含むspan要素を削除
$("span:contains(" + checkVal + ")").remove();
}
})
//リセットボタンをクリックした際の処理
$("[type='reset']").on("click",function(){
//span要素を削除
$("span").remove();
})
})
Also see: Tab Triggers