Maarten Wolfsen Maarten Wolfsen - 1 year ago 73
jQuery Question

If statement not working after minimization

I had an if statement inside a scroll function, to check if the div

or the div
exists. It was something like this:

if($('#homepage-flag').length > 0 || $('#landingspage-flag').length > 0){
// code

I minified the code, but now the if statement only works for the div

$("#homepage-flag").length > 0 || $("#landingspage-flag").length > 0 && $(window).scroll(function(l) {
// code

Answer Source

The minified code is completely wrong. The minified version should be something like :

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download