To answer your question:
if (myposition == "true") {
does not work as expected, because myposition- this is a boolean value truethat is not equal to the value of string "true" .
You may wonder why mypositionis a boolean. This is because jQuery converts it to a boolean :
JavaScript ( , , , ).
, , , , booleans :
if (myposition) {
$(this).html("afficher le lecteur");
$('#audioWelcome').data('myposition', false);
} else {
$(this).html("cacher le lecteur");
$('#audioWelcome').data('myposition', true);
}
:
$(this).html(myposition ? "afficher le lecteur" : "cacher le lecteur");
$('#audioWelcome').data('myposition', !myposition);
DEMO