J'ai quelques exemples de code comme cecireturn false/développement web javascript/jquery
---------------------- Premier exemple ---- -------------
var rightFunction=function() {
if (options.currentPage < options.numberOfPages) {
options.currentPage += 1;
ajaxConnection();
}
return false;
};
$('#newsContainer #rightSlider').click(rightFunction);
$('#rightSliderHigh').click(rightFunction);
---------------------- Deuxième exemple ------ -------------
$('#rightSliderPagination').click(function(){
if (parseInt(_pagina_last_link.html()) >= options.numberOfPages) {
return false;
}
_first_page_num = parseInt(_pagina_first_link.html());
paginationGenerator(_first_page_num + options.centerNumber - 1);
$('#slider-inner').slider("option", "value", _first_page_num + options.centerNumber - 1);
return false;
});
------------------------ Troisième exemple ---- ------------------
$(".download").click(function(){
if($(this).attr('goToPage')=='true') {
var url=$(this).attr('href');
document.location.href=url;
return false;
}
var _this = $(this);
var thistext = $("#bg-download-box").html();
var _whattoshow = $(this).parent().find(".what-to-show").html();
if (_whattoshow){
$("#bg-download-box form").html(_whattoshow);
}
else{
$("#bg-download-box").html("<div id='bg-download-box-inner' style='height:132px'></div>");
}
if ($(".reccomend-box").length != 0){
$("#rightColumn").css("z-index",99999);
}
$("#bg-download-box").show();
var whattocopy = $("#bg-download-box");
$(whattocopy).insertAfter(_this);
$("ul#songs-list").css("z-index","99999");
$("ul#songs-list li.b-a-r").removeClass("emph");
$(this).parent().parent().parent().addClass("emph");
return false;
});
Pourquoi est-ce que return false est utilisé à la fin de ces fonctions. S'il vous plaît, quelqu'un pourrait expliquer le but de retour faux.
Veuillez expliquer ce que votre code suppose de faire pour que les gens puissent vous aider facilement – Khalid
D'où vient ce code? Je ne pense pas qu'il y ait une raison pour laquelle ces fonctions doivent retourner une valeur. Voici la documentation jQuery pertinente: http://api.jquery.com/click/ – VinceFior
@Khalid, je pense que le mur o 'code est sans rapport avec la question. OP se soucie seulement de 'return false' – paqogomez