I have a problem, I have made a script that runs through all images and takes the href of the image and puts it to each buy button under the image. Every image has a buy button underneedth.
But when there is an image without a link the script stops and does not continue to the end.
How could I make it continue till the end?
Found somewhere that return non-false; is like continue, but did not work.
Not allowed to put markup sorry.
$('.productImg a').each(function(){
if($(this).attr('href').indexOf("sometext")> 0 && $(this).attr('href').indexOf("sometext") != 'undefined'){
$(this).parents(".item").find(".BuyLink a").attr('href',$(this).attr('href'));
}
else if ($(this).attr('href').indexOf("sometext") == 'undefined') {
return non-false;
}
});
return trueis the best advice. Your code is creating an error because your are returning an undefined variable I suspect.indexOf(...)will never, ever return the stringundefined. If the string is not found it returns-1.