我的javascript代码如下:
;(function($){
$.ag.hideScrollbar = function (currentWidth) {
...
};
// not executed
//start
$.ag.initMap = function(mapCanvas){
...
};
$.ag.initMapAutocomplete = function () {
...
};
//end
}(jQuery));
我希望地图脚本不被执行
我不想评论这个剧本。我想为脚本添加一个不运行的条件
我该怎么做?
答案 0 :(得分:1)
您可以向该函数添加if
语句
类似的东西:
;(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))