Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8344147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:16:26+00:00 2026-06-09T06:16:26+00:00

I found a wonderful jsfiddle that someone has made and wanted to use part

  • 0

I found a wonderful jsfiddle that someone has made and wanted to use part of it in my project:

http://jsfiddle.net/manuel/29gtu/

It works on the jsfiddle but not in my HTML document. Here is what in my document:

<!DOCTYPE html>
<html>
<head>
<script src="scripts/jquery-1.7.2.js"></script>

<script>

$("button").click(function() {
    var id = $("#id").val();
    var text = "icon-"+id;
    // update the result array
    var result = JSON.parse(localStorage.getItem("result"));
    if(result == null)
        result = [];

    result.push({id: id, icon: text});
    // save the new result array
    localStorage.setItem("result", JSON.stringify(result));

    // append the new li
    $("#bxs").append($("<li></li>").attr("id", "item-"+id).html(text));
});

// on init fill the ul
var result = JSON.parse(localStorage.getItem("result"));
if(result != null) {
    for(var i=0;i<result.length;i++) {
        var item = result[i];
        $("#bxs").append($("<li></li>").attr("id", "item-"+item.id).html(item.icon));
    }
}​

</script>
</head>

<body>
<ul id="bxs" class="tabs"> 
</ul>

<input type="text" id="id" /><button>save</button>
</body>
</html>

The code is copied and pasted from the fiddle. I think it has to do with me not having a plugin for local storage.
For that jsfiddle to work, do I need some external plugin that I am missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T06:16:28+00:00Added an answer on June 9, 2026 at 6:16 am

    You should wrap your whole code within $(document).ready(function() {...});

    So.

    <script type="text/javascript">
    
        $(document).ready(function() {
            $("button").click(function() {
                var id = $("#id").val();
                var text = "icon-" + id;
                // update the result array
                var result = JSON.parse(localStorage.getItem("result"));
                if (result == null) result = [];
    
                result.push({
                    id: id,
                    icon: text
                });
                // save the new result array
                localStorage.setItem("result", JSON.stringify(result));
    
                // append the new li
                $("#bxs").append($("<li></li>").attr("id", "item-" + id).html(text));
            });
    
            // on init fill the ul
            var result = JSON.parse(localStorage.getItem("result"));
            if (result != null) {
                for (var i = 0; i < result.length; i++) {
                    var item = result[i];
                    $("#bxs").append($("<li></li>").attr("id", "item-" + item.id).html(item.icon));
                }
            }
    
        });
    
    </script>
    

    Note

    In jsfiddle onLoad mode do that for you, i.e. when you select onLoad from left side panel drop down, then all js code execute after all resources become appeared in the DOM.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using this wonderful jquery plugin found here... http://appgrinders.github.com/jquery-easy-drop-down/ Only problem is, it doesn't
I'm Following the wonderful Michael Hartl's tutorial which can be found here: http://ruby.railstutorial.org/ I'm
I found this wonderful clone function for javascript ( http://my.opera.com/GreyWyvern/blog/show.dml/1725165 ), but it breaks
I just found out today that WPF will ignore CultureInfo.CurrentCulture and always use en-US.
I found a wonderful open source Java program that I'm translating into C#. The
I just found the wonderful ElasticFox , a Firefox plugin that makes working with
I found this great code snippet that works wonderfully during circumstances that change a
found this little code snippet that seems to do what i want, but im
Found a piece of code today, that I find a little smelly... TMyObject.LoadFromFile(const filename:
I just found Bathisar Tidy to tidy up HTML on a Mac. Wonderful app

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.