I want to achieve the following:
If a country other than Germany (de) is selected from a selection list and the "print" tab is currently selected, the "digital" tab should be selected, the page should be scrolled upwards and an alert box should be displayed.
My code works so far, but the second condition of the second if loop is not evaluated:
if (this.value! = 'de' && $("input [value = 'print']"). prop ("checked", true)) {
..
}
For this reason, every time you select from the selection list, the tab is changed to "digital" and the page scrolls upwards, although it should only be the case with a selected "print" tab.
Here is my complete code:
// if a country other than germany is elected, set selected tab to digital and scroll to top
$("select[name='country']").change(function(e){
$("select[name='country'] option").each(function() {
if (this.selected) {
if (this.value != 'de' && $("input[value='print']").prop("checked", true) ) {
$("input[value='digital']").prop("checked", true);
$("form .alert").css({display: 'block'});
var target = $('#top');
$('html, body').animate({
scrollTop:$(target).offset().top
},'slow');
e.preventDefault();
}
}
});
});
And here is the page with the described tabs and the selection list:
https://www.academyofsports.de/de/anmeldung/fernstudium.html?product=fitness-c-lizenz
Aucun commentaire:
Enregistrer un commentaire