Jump to content
m.s_shohan

How can I resolve these javaScript errors or bugs ?

Recommended Posts

Hi,I am developing my first website template. When I used this script in the internal script, it ran well. But when I added this script inside a file,the jsLint showed that there was almost 20 errors. Here I am sending the screen of the errors. Can you please help me to understand why these errors occurred and how can I resolve these? Here is the script:

            function openModalSearch() {
                 'use strict';
            var modalSearch = document.getElementById("modal-search-container");
                modalSearch.style.height = "100%";
       }
            function closeModalSearch() {
                 'use strict';
             document.getElementById("modal-search-container").style.height = "0%";
       }
            function hideSearch() {
                'use strict';
                document.getElementById("search-container").style.visibility = "hidden";
            }
            function showSearch(){
                'use strict'
                document.getElementById("search-container").style.visibility = "visible";
            }

Thank you in advance......

post-201838-0-45366100-1478013157_thumb.png

Share this post


Link to post
Share on other sites

It's complaining about bad indentation. You're opening the function at one level of indentation but closing it at a different level.

 

Almost all the lines in your code have bad indentation. Here's an example:

 

Your code:

            function openModalSearch() {
                 'use strict';
            var modalSearch = document.getElementById("modal-search-container");
                modalSearch.style.height = "100%";
       }

Proper indentation:

function openModalSearch() {
    'use strict';
    var modalSearch = document.getElementById("modal-search-container");
    modalSearch.style.height = "100%";
}

You also forgot to end the 'use strict' line with a semi-colon here:

function showSearch(){
    'use strict' // NEEDS SEMI-COLON
    document.getElementById("search-container").style.visibility = "visible";
}
Edited by Ingolme

Share this post


Link to post
Share on other sites

Thank you so much. I got the point and resolved it. This is a great forum for the beginners. Thank you so much.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...