<html>
<head>
<title>My page title</title>
<link href='http://fonts.googleapis.com/css?family=Raleway|Crushed' rel='stylesheet' type='text/css'>
</head>
<body>
<h1>Transformers</h1>
<div class="intro">
<p>This is my page about transformers. They are a <em>really cool</em> toy from the 1980's, which have remained popular ever since.</p>
<h2>The types of transformer</h2>
<p>There are two types of transformer — the <strong>Autobots</strong> are good, and the <strong>Decepticons</strong> are evil. My favourite transformers are:</p>
<ul>
<li>Soundwave (Decepticon)</li>
<li>Grimlock (Autobot)</li>
<li>Starscream (Decepticon)</li>
<li>Hotrod (Autobot)</li>
<li>Devastator (Decepticon)</li>
</ul>
<p>Find out more at the <a href="http://www.hasbro.com/transformers/en_US/">Transformers official site</a>.</p>
<button>Change user</button>
</div>
<div class="gallery">
<img src="http://images1.wikia.nocookie.net/__cb20100504224027/transformers/images/7/78/G1_soundwave.png" alt="The decepticon Soundwave" width="300" class="imgSwap">
<iframe width="420" height="315" src="//www.youtube.com/embed/RJ90S04cST4" frameborder="0" allowfullscreen></iframe>
</div>
</body>
</html>
var myImage = document.querySelector('.imgSwap');
myImage.onclick = function() {
var mySrc = myImage.getAttribute('src');
if(mySrc === 'http://images1.wikia.nocookie.net/__cb20100504224027/transformers/images/7/78/G1_soundwave.png') {
myImage.setAttribute ('src','http://unrealbooks.com/catalog/images/Galvatron_flat.jpg');
} else {
myImage.setAttribute ('src','http://images1.wikia.nocookie.net/__cb20100504224027/transformers/images/7/78/G1_soundwave.png');
}
};
var myButton = document.querySelector('button');
var myHeading = document.querySelector('h1');
function setUserName() {
var myName = prompt('Please enter your name.');
localStorage.setItem('name', myName);
myHeading.innerHTML = 'Hello, ' + myName + '!';
}
if(!localStorage.getItem('name')) {
setUserName();
} else {
var storedName = localStorage.getItem('name');
myHeading.innerHTML = 'Hello, ' + storedName + '!';
}
myButton.onclick = function() {
setUserName();
};
Output
This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account
Dismiss xKeyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |