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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×