<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
<!--
/**
* Lists blog entries from the specified JSON feed
* by creating a new 'ul' element in the DOM. Each
* bullet is the title of one blog entry, and contains
* a hyperlink to that entry's URL.
*
* @param {JSON} json is the JSON object pulled from the Blogger service.
*/
function listEntries(json) {
// Clear any information displayed under the "data" div.
removeOldResults();
var ul = document.createElement('ul');
for (var i = 0; i < json.feed.entry.length; i++) {
var entry = json.feed.entry[i];
var alturl;
for (var k = 0; k < entry.link.length; k++) {
if (entry.link[k].rel == 'alternate') {
alturl = entry.link[k].href;
break;
}
}
var li = document.createElement('li');
var a = document.createElement('a');
a.href="/gdata/samples/alturl;"
a.target = '_blank';
var txt = document.createTextNode(entry.title.$t);
a.appendChild(txt);
li.appendChild(a);
ul.appendChild(li);
}
// Install the bullet list of blog posts.
document.getElementById('data').appendChild(ul);
// Re-enable the search button.
var search_button = document.getElementById('search_button');
search_button.removeAttribute('disabled');
}
/**
* Called when the user clicks the 'Search' button to
* retrieve a blog's JSON feed. Creates a new script
* element in the DOM whose source is the JSON feed
* 'query'.blogspot.com, and specifies that the callback
* function is 'listEntries' (above).
*
* @param {String} query is the blog to be retrieved, specified
* as a prefix of ".blogspot.com".
*/
function search(query) {
// Delete any previous JSON script nodes.
// Clear any old data to prepare to display the Loading... message.
// Show a "Loading..." indicator.
var div = document.getElementById('data');
var p = document.createElement('p');
...
JavaScript
var select = document.querySelector(".testSelect");
var selectOption = select.options[select.selectedIndex];
var lastSelected = localStorage.getItem('select');
if(lastSelected) {
select.value = lastSelected;
}
select.onchange = function () {
lastSelected = select.options[select.selectedIndex].value;
console.log(lastSelected);
localStorage.setItem('select', lastSelected);
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.