Can someone tell me why this isent working:
// ---------- START: Activate save button on change from default values ---------- //
// Get old values
var Old_Email_Value = $('#User-Email-Profile').val();
var Old_Phone_Value = $('#User-Phone-Profile').val();
var Old_ImgSrc_Value = $('.Content-Image-Main').find('img').attr('src');
function ProfileChange() {
// If new values, change button to active
$('#User-Email-Profile, #User-Phone-Profile, #Profile-Img-Edit').on('input load', function() {
var New_Email_Value = $('#User-Email-Profile').val();
var New_Phone_Value = $('#User-Phone-Profile').val();
var New_ImgSrc_Value = $('.Content-Image-Main').find('img').attr('src');
console.log(Old_Email_Value + ' ' + New_Email_Value + Old_Phone_Value + ' ' + New_Phone_Value);
console.log(Old_ImgSrc_Value);
if (Old_Email_Value !== New_Email_Value || Old_Phone_Value !== New_Phone_Value || Old_ImgSrc_Value !== New_ImgSrc_Value) {
$('#Save-Profile-Content').css('opacity', '1');
$('#Save-Profile-Content').css('cursor', 'pointer');
} else {
$('#Save-Profile-Content').css('opacity', '0.6');
$('#Save-Profile-Content').css('cursor', 'default');
}
});
}
$(document).ready(function() {
ProfileChange();
});
// ---------- END: Activate save button on change from default values ---------- //
For some reason the OR operator is not working, i want it to activate the button if any of the new input values are different from the old ones or if there is a new image src.
Tested all the values they come back, as they should but there is something wrong with the if statement.
Aucun commentaire:
Enregistrer un commentaire