0

My javascript code like this :

;(function($){

    $.ag.hideScrollbar = function (currentWidth) {
        ...
    };

    // not executed
    //start
    $.ag.initMap = function(mapCanvas){
        ...
    };
    $.ag.initMapAutocomplete = function () {
        ...
    };
    //end

}(jQuery));

I want map script not executed

I do not want to comment the script. I want to add a condition for the script not to run

How can I do it?

1
  • 3
    I want to add a condition .. if (condition) { .... } Commented Mar 29, 2018 at 0:28

1 Answer 1

1

you can add an if statement to that function

something like :

;(function($) {

  if (element.length > 0) { //or whatever condition you need to test
    $.ag.hideScrollbar = function(currentWidth) {
      ...
    };
  }

  // not executed
  //start
  $.ag.initMap = function(mapCanvas) {
    ...
  };
  $.ag.initMapAutocomplete = function() {
    ...
  };
  //end

}(jQuery))

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.