I have one jquery method and i used call that method on click of a button .
So in that code i have one line \" $(\"#loadingMessage\").css(\'padding-top\',\'6%\');
use .one for once and use click for others.check below
<script>
$(document).ready(function() {
$('#SearchButton').one('click', function() {
$("#loadingMessage").css('padding-top','6%'); //I want this line execute only once, i mean first time
});
$('#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;
});
} );
</script>
quick and 'dirty' solution:
$.first_time = true;
$('#SearchButton').click(function() {
if($.first_time == true) $("#loadingMessage").css('padding-top','6%');
$.first_time = false;
});
some explanation: you need a global jQuery
variable here ($.first_time
in this example), so that it's still known inside the anonymous function of the click event.
you can use bolean in all languages.
in jquery:
var isFirst = true;
if(isFirst){
$("#loadingMessage").css('padding-top','6%');
isFirst=false;
}