How to execute Jquery code only once??
Use jQuery .one(). When using .one() method, the event handler function is only run once for each element.
$('#SearchButton').one("click", function () {
$("#loadingMessage").css('padding-top', '6%');
});
$('#SearchButton').click(function () {
$(".spinner").css('visibility', 'hidden');
loaderStart();
document.getElementById('loadinggif3').style.display = "block";
$("#loadinggif3").show();
$(".col-sm-9").css('visibility', 'hidden');
var str = $('#SearchText').val();
str = str.trim();
if (str == "") return false;
});
Use a boolean as a global variable, like
var flag = true;
Now, set the condition before the execution, Like
if(flag){
$("#loadingMessage").css('padding-top','6%');
flag=false;
}