I have a variety of HTML cards with different text languages. I want to dynamically align the text inside the cards based on the language - if the card title is in Urdu or Arabic, I want the text to be aligned right. If the card title is in English, then I want to set it to align left.
Is there a way to achieve this using jQuery or JavaScript? I'm seeking a solution and would appreciate any assistance.
$(document).ready(function() {
if (language === 'ur') {
$('.title').css('text-align', 'right');
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="hpanel blog-box">
<div class="title">
<h4>اسلام آباد: پاکستان ٹیلی کمیونکیشن اتھارٹی (پی ٹی اے) نے اسلام آباد ہائیکورٹ کو آگاہ کیا ہے کہ اس</h4>
</div>
</div>
<div class="hpanel blog-box">
<div class="title">
<h4>I'm not entirely sure what's going on, especially as the value in the dictionary has been updated.</h4>
</div>
</div>