SCRIPT JS SELON ID D’UN ARTICLE WP
Posté : 14 janv. 2020, 08:20
Bonjour,
Comme le titre du sujet l’indique, j’ai intégré dans le fichier header.php de mon site WordPress un script js pour effectuer une action hide/show.
Problématique : n’étant pas une experte js, j’ai intégré l’ID de l’article dans chaque script (ce qui n’est pas très dynamique et viable).
Quelqu’un aurait-il le morceau de code qui va bien ?
Merci d’avance.
Comme le titre du sujet l’indique, j’ai intégré dans le fichier header.php de mon site WordPress un script js pour effectuer une action hide/show.
Problématique : n’étant pas une experte js, j’ai intégré l’ID de l’article dans chaque script (ce qui n’est pas très dynamique et viable).
Quelqu’un aurait-il le morceau de code qui va bien ?
Merci d’avance.
Code : Tout sélectionner
[code]<script>
$(function(){
$('article#4006 .affiche-clic').hide()
$('article#4006 .moins').hide()
$('article#4006 .triangle-code-moins').hide()
});
$(function(){
$('article#4006 div.infos-offres a.clic-plus').click(function(){
$('article#4006 div.infos-offres div.affiche-clic').show()
$('article#4006 .moins').show()
$('article#4006 .plus').hide()
$('article#4006 .triangle-code').hide()
$('article#4006 .triangle-code-moins').show()
});
});
$(function(){
$('article#4006 div.infos-offres a.clic-moins').click(function(){
$('article#4006 div.infos-offres div.affiche-clic').hide()
$('article#4006 .plus').show()
$('article#4006 .triangle-code').show()
$('article#4006 .triangle-code-moins').hide()
$('article#4006 a.clic-moins').hide()
});
});
$(function(){
$('article#4006 .triangle-code-moins').click(function(){
$('article#4006 div.infos-offres div.affiche-clic').hide()
$('article#4006 .plus').show()
$('article#4006 .triangle-code').show()
$('article#4006 .triangle-code-moins').hide()
$('article#4006 a.clic-moins').hide()
});
});
</script>