Glen O
0
Q:

jquery if else on click

$('#myElementID').click(function() {
	var isSomethingTrue = true;
    
    if(isSomethingTrue){
    	alert("something is true");
    }else{
    	alert("something is false");
    }
});
0
$(document).ready(function(){ 

	var n = $("#example div").length;

	if (n < 2) {
		$("body").css("background", "green");
	} 
	else {
		$("body").css("background", "orange");
	}

});
0

New to Communities?

Join the community