Last active
December 18, 2020 04:24
-
-
Save tieutantan/dba0f8402c57627d91823558ed28f6d5 to your computer and use it in GitHub Desktop.
English in text detection JS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function changeEngFont(selector) { | |
$(selector).contents().each(function () { | |
if (this.nodeType === 3) { | |
} else { | |
let value = this.innerHTML; | |
let isEnglish = value.search(/[^a-zA-Z]+/); | |
if(isEnglish === -1 || isEnglish === 3) { | |
$(this).css("font-family", "Baskerville, serif"); | |
} | |
} | |
}); | |
} | |
changeEngFont(".content-box"); // shop pane | |
changeEngFont("#shop_single .text"); // shop single | |
changeEngFont(".slider-title"); // home slider |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="slider-title"> | |
<p class="caption"><?php echo $slide->title; ?></p> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment