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 8755631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:53:36+00:00 2026-06-13T13:53:36+00:00

Im getting an Uncaught Syntax Error: Unexpected Identifier error in my javascript code on.

  • 0

Im getting an “Uncaught Syntax Error: Unexpected Identifier” error in my javascript code on. This code is basically just a 1 to 1 copy from a tutorial which I adapted to fit to my html file.The error occurs on line 86 within the “Create StickyNote” function.
Here goes the code:

(function ($, $S) {
//$ jQuery
//$S window.localStorage
//Variables Declaration
var $board = $('#board'),
    //Board where the stickyNotes are stuck
    stickyNoteClass, //Singleton Object containing the Functions to work with the LocalStorage
    len = 0,
    //Length of Objects in the LocalStorage 
    currentNotes = '',
    //Storage the html construction of the stickyNotes
    o; //Actual stickyNoteClass data in the localStorage



//Manage the stickyNotes in the Local Storage
//Each stickyNote is saved in the localStorage as an Object  
stickyNoteClass = {
    add: function (obj) {
        obj.id = $S.length;
        $S.setItem(obj.id, JSON.stringify(obj));
    },

    retrive: function (id) {
        return JSON.parse($S.getItem(id));
    },

    remove: function (id) {
        $S.removeItem(id);
    },

    removeAll: function () {
        $S.clear();
    }

};

//If any stickyNote exists, Create it/them
len = $S.length;
if (len) {
    for (var i = 0; i < len; i++) {
        //Create all stickyNotes saved in localStorage
        var key = $S.key(i);
        o = stickyNoteClass.retrive(key);
        currentNotes += '<div class="stickyNote"';
        currentNotes += ' style="left:' + o.left;
        currentNotes += 'px; top:' + o.top;
        //data-key is the attribute to know what item delete in the localStorage
        currentNotes += 'px"><div class="toolbar"><span class="delete" data-key="' + key;
        currentNotes += '">x</span></div><div contenteditable="true" class="editable">';
        currentNotes += o.text;
        currentNotes += '</div></div>';
    }

    //Append all the stickyNotes to the board
    $board.html(currentNotes);
}

/*Dont need to implement this one, as it is already implemented in the html index file
---------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------
//When the document is ready, make all stickyNotes Draggable
$(document).ready(function () {
    $(".stickyNote").draggable({
        cancel: '.editable',
        "zIndex": 3000,
        "stack" : '.stickyNote'
    });
});*/

//Remove stickyNoteClass
$('span.delete').live('click', function () {
    if (confirm('Are you sure you want to delete this Note?')) {
        var $this = $(this);
        //data-key is the attribute to know what item delete in the localStorage
        stickyNote.remove($this.attr('data-key'));
        $this.closest('.stickyNote').fadeOut('slow', function () {
            $(this).remove();
        });
    }
});

//Create stickyNote
$('#new stickyNote').click(function () {
    $board.append('<div class="stickyNote" style="left:20px;top:70px">
            <span class="delete" title="Close">x</span>
            <h1>Drag Me</h1>
            <p class="editable">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum..</p>
</div>');

    /*Dont need to do this, as the draggable is implemented in the html file for all
    divs which are placed within the #board.
    ------------------------------------------------------------------------------------
    ------------------------------------------------------------------------------------
    $(".stickyNote").draggable({
        cancel: '.editable'
    });*/
});

//Save all the stickyNotes when the user leaves the page
window.onbeforeunload = function () {
    //Clean the localStorage
    stickyNoteClass.removeAll();
    //Then insert each stickyNote into the LocalStorage
    //Saving their position on the page, in order to position them when the page is loaded again
    $('.stickyNote').each(function () {
        var $this = $(this);
        stickyNoteClass.add({
            top: parseInt($this.position().top),
            left: parseInt($this.position().left),
            text: $this.children('.editable').text()
        });
    });
}
})(jQuery, window.localStorage);
  • 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-13T13:53:37+00:00Added an answer on June 13, 2026 at 1:53 pm

    As @FelixKling has pointed out, a multiline string is not allowed the way you have it. Change this:

    $('#new stickyNote').click(function () {
        $board.append('<div class="stickyNote" style="left:20px;top:70px">
                <span class="delete" title="Close">x</span>
                <h1>Drag Me</h1>
                <p class="editable">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum..</p>
    </div>');
    
        /*Dont need to do this, as the draggable is implemented in the html file for all
        divs which are placed within the #board.
        ------------------------------------------------------------------------------------
        ------------------------------------------------------------------------------------
        $(".stickyNote").draggable({
            cancel: '.editable'
        });*/
    });
    

    to this:

        $board.append('<div class="stickyNote" style="left:20px;top:70px">' +
                '<span class="delete" title="Close">x</span>' +
                '<h1>Drag Me</h1>' +
                '<p class="editable">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum..</p>' +
                '</div>');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hello im am getting JS error : Uncaught SyntaxError: Unexpected identifier here <script type=text/javascript>
I'm getting this JavaScript error on my console: Uncaught SyntaxError: Unexpected token ILLEGAL This
I am getting this error Uncaught SyntaxError: Unexpected token < from chrome but everything
I keep getting this error: Uncaught Syntax Error: Unexpected Token ILLEGAL while running Ext
I am getting a Uncaught Syntax Error: Unexpected Identifier in the Chrome Console Window.
I am getting this Uncaught SyntaxError: Unexpected identifier error , Why ? I think
I'm getting this exception from facebook SDK: Fatal error: Uncaught OAuthException: (#506) Duplicate status
I keep getting this error: Error: uncaught exception: Syntax error, unrecognized expression: [object Object]
I am getting the following error: Uncaught SyntaxError: Unexpected token ILLEGAL and this is
I'm getting this: Uncaught Error: Syntax error, unrecognized expression: [data-id=1|31|2] So what I gather

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.