I’ve got three languages on my website, and I hide/show the appropriate language on click… Each div containing content is labeled with a class for that language, but I’m just wondering if there is a more streamline way to write the hide/shows, like with a loop or switch statement or something…
Thoughts? This way just seems too redundant. here is my code:
jQuery( document ).ready(function( $ ) {
$(".tr-chinese").click(function() {
$(".chinese").show();
$(".english").hide();
$(".german").hide();
});
$(".tr-german").click(function() {
$(".german").show();
$(".chinese").hide();
$(".english").hide();
});
$(".tr-english").click(function() {
$(".english").show();
$(".chinese").hide();
$(".german").hide();
});
});
Then divs would be like
<div class="english">Some text</div> <div class="chinese"> Some chinese text</div> <div class="german"> Some German text</div>
Thoughts? Suggestions?