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.
<div id="app" class="container mb-4">
<h1 class="font-weight-light text-center mb-3 mt-2">
Library Borrowing System
</h1>
<table class="table table-striped">
<thead>
<tr>
<th scope="col">No.</th>
<th scope="col">Title</th>
<th scope="col">Author</th>
<th scope="col">Description</th>
<th scope="col">Actions</th>
</tr>
</thead>
<tbody>
<tr v-for="(book, index) in books">
<th scope="row">{{ index + 1 }}</th>
<td>{{ book.title }}</td>
<td>{{ book.author }}</td>
<td>{{ book.description }}</td>
<td>
<button :disabled="book.availableNumber < 2 || isBorrowed(book)"
@click="borrowBook(book)"
type="button" class="btn btn-primary btn-sm">
Borrow{{ isBorrowed(book) ? 'ed' : '' }}
</button>
</td>
</tr>
</tbody>
</table>
</div>
button:not([disabled]) {
cursor: pointer;
}
$(document).ready(() => {
new Vue({
el: '#app',
data: {
books: [],
borrowedBooks: []
},
created() {
this.books = getData()
},
methods: {
borrowBook(book) {
this.borrowedBooks.push(book.id)
toastr.success(book.id, 'Borrowed Book!')
},
isBorrowed(book) {
return this.borrowedBooks.find(id => book.id === id) !== undefined
}
},
watch: {
books() {
if (!$.fn.DataTable.isDataTable('table'))
$('table').DataTable()
}
}
})
})
getData = () => [
{
"id": "9781593275846",
"title": "Eloquent JavaScript, Second Edition",
"author": "Marijn Haverbeke",
"description": "JavaScript lies at the heart of almost every modern web application, from social apps to the newest browser-based games. Though simple for beginners to pick up and play with, JavaScript is a flexible, complex language that you can use to build full-scale applications.",
"availableNumber": 2
},
{
"id": "9781449331818",
"title": "Learning JavaScript Design Patterns",
"author": "Addy Osmani",
"description": "With Learning JavaScript Design Patterns, you'll learn how to write beautiful, structured, and maintainable JavaScript by applying classical and modern design patterns to the language. If you want to keep your code efficient, more manageable, and up-to-date with the latest best practices, this book is for you.",
"availableNumber": 3
},
{
"id": "9781449365035",
"title": "Speaking JavaScript",
"author": "Axel Rauschmayer",
"description": "Like it or not, JavaScript is everywhere these days-from browser to server to mobile-and now you, too, need to learn the language or dive deeper than you have. This concise book guides you into and through JavaScript, written by a veteran programmer who once found himself in the same position.",
"availableNumber": 1
},
{
"id": "9781491950296",
"title": "Programming JavaScript Applications",
"author": "Eric Elliott",
"description": "Take advantage of JavaScript's power to build robust web-scale or enterprise applications that are easy to extend and maintain. By applying the design patterns outlined in this practical book, experienced JavaScript developers will learn how to write flexible and resilient code that's easier-yes, easier-to work with as your code base grows.",
"availableNumber": 4
},
{
"id": "9781593277574",
"title": "Understanding ECMAScript 6",
"author": "Nicholas C. Zakas",
"description": "ECMAScript 6 represents the biggest update to the core of JavaScript in the history of the language. In Understanding ECMAScript 6, expert developer Nicholas C. Zakas provides a complete guide to the object types, syntax, and other exciting changes that ECMAScript 6 brings to JavaScript.",
"availableNumber": 4
},
{
"id": "9781491904244",
"title": "You Don't Know JS",
"author": "Kyle Simpson",
"description": "No matter how much experience you have with JavaScript, odds are you don’t fully understand the language.",
"availableNumber": 2
},
{
"id": "9781449325862",
"title": "Git Pocket Guide",
"author": "Richard E. Silverman",
"description": "This pocket guide is the perfect on-the-job companion to Git, the distributed version control system. It provides a compact, readable introduction to Git for new users, as well as a reference to common commands and procedures for those of you with Git experience.",
"availableNumber": 1
},
{
"id": "9781449337711",
"title": "Designing Evolvable Web APIs with ASP.NET",
"author": "Glenn Block, et al.",
"description": "Design and build Web APIs for a broad range of clients—including browsers and mobile devices—that can adapt to change over time. This practical, hands-on guide takes you through the theory and tools you need to build evolvable HTTP services with Microsoft’s ASP.NET Web API framework. In the process, you’ll learn how design and implement a real-world Web API.",
"availableNumber": 3
},
{
"id": "9781593275846",
"title": "Eloquent JavaScript, Second Edition",
"author": "Marijn Haverbeke",
"description": "JavaScript lies at the heart of almost every modern web application, from social apps to the newest browser-based games. Though simple for beginners to pick up and play with, JavaScript is a flexible, complex language that you can use to build full-scale applications.",
"availableNumber": 2
},
{
"id": "9781449331818",
"title": "Learning JavaScript Design Patterns",
"author": "Addy Osmani",
"description": "With Learning JavaScript Design Patterns, you'll learn how to write beautiful, structured, and maintainable JavaScript by applying classical and modern design patterns to the language. If you want to keep your code efficient, more manageable, and up-to-date with the latest best practices, this book is for you.",
"availableNumber": 3
},
{
"id": "9781449365035",
"title": "Speaking JavaScript",
"author": "Axel Rauschmayer",
"description": "Like it or not, JavaScript is everywhere these days-from browser to server to mobile-and now you, too, need to learn the language or dive deeper than you have. This concise book guides you into and through JavaScript, written by a veteran programmer who once found himself in the same position.",
"availableNumber": 1
},
{
"id": "9781491950296",
"title": "Programming JavaScript Applications",
"author": "Eric Elliott",
"description": "Take advantage of JavaScript's power to build robust web-scale or enterprise applications that are easy to extend and maintain. By applying the design patterns outlined in this practical book, experienced JavaScript developers will learn how to write flexible and resilient code that's easier-yes, easier-to work with as your code base grows.",
"availableNumber": 4
},
{
"id": "9781593277574",
"title": "Understanding ECMAScript 6",
"author": "Nicholas C. Zakas",
"description": "ECMAScript 6 represents the biggest update to the core of JavaScript in the history of the language. In Understanding ECMAScript 6, expert developer Nicholas C. Zakas provides a complete guide to the object types, syntax, and other exciting changes that ECMAScript 6 brings to JavaScript.",
"availableNumber": 4
},
{
"id": "9781491904244",
"title": "You Don't Know JS",
"author": "Kyle Simpson",
"description": "No matter how much experience you have with JavaScript, odds are you don’t fully understand the language.",
"availableNumber": 2
},
{
"id": "9781449325862",
"title": "Git Pocket Guide",
"author": "Richard E. Silverman",
"description": "This pocket guide is the perfect on-the-job companion to Git, the distributed version control system. It provides a compact, readable introduction to Git for new users, as well as a reference to common commands and procedures for those of you with Git experience.",
"availableNumber": 1
},
{
"id": "9781449337711",
"title": "Designing Evolvable Web APIs with ASP.NET",
"author": "Glenn Block, et al.",
"description": "Design and build Web APIs for a broad range of clients—including browsers and mobile devices—that can adapt to change over time. This practical, hands-on guide takes you through the theory and tools you need to build evolvable HTTP services with Microsoft’s ASP.NET Web API framework. In the process, you’ll learn how design and implement a real-world Web API.",
"availableNumber": 3
}
]
Also see: Tab Triggers