I have a blog in two languages. i want to toggle between language A and B when clicking FlagA.png or FlagB.png. Every post contains at least two flags images. How can I do this using (bootstrap) Jquery? (context, I dont have a DB, in order to facilitate multi languages I want to make use of the toggle functions)
<div class="post">
<div class="post-content">
<div class="post-title"><a href="#"><b>title</b</a> </div>
<a href="" class="languageA">
<img src="img/countryA.png" alt=""
style="float: right;" /></a>
<a href="" class="languageB">
<img src="img/countryB.png" alt="" style="float: right;
padding-right: 10px;" /></a>
</br>
<div class="post-description">
<p>
post in language A
</p>
</div>
<div class="post-description">
<p>
post in language B but now it is invisible, when pressed countryB image this becomes visible and post in language A not.
</p>
</div>
<p class="test"> test test test test test test test test test test test test</p>
</div>
<div class="post">
<!-- second post\-->
</div>
<!-- -->
<script type="text/jscript">
$(function() {
$('.languageA').click(function () {
$('.test').collapse({
toggle: true
})
});
});
});
</script>
You can do this by the following method:
$(this).parentso you could read one post in one language and another in a different language.Here is the HTML:
And then the following JavaScript will toggle the language:
JSFiddle is here.