I am building a bilingual website using wix code to show and hide the corresponding field. The code worked a couple of weeks ago but suddenly I found that it does not work now.
Now what is shown is that both English and Chinese fields are overlapping each other in the live site while it works normally in the preview mode. Below is the piece of code for your reference. If any line of the code works, either English or Chinese fields should be hidden regardless of the language.
I have checked the website history. There is no one who made any changes to the website in the past days.
Anyone can help?
// API Reference: https://www.wix.com/corvid/reference
// “Hello, World!” Example: https://www.wix.com/corvid/hello-world
import wixWindow from ‘wix-window’ ;
$w.onReady( function () {
// Write your JavaScript here
// To select an element by ID use: $w(“#elementID”)
let language = wixWindow.multilingual.currentLanguage; // “en”
if (language === “en” ) {
$w( '#shortDescription' ).show();
$w( '#text123' ).hide();
} **else** {
$w( '#shortDescription' ).hide();
$w( '#text123' ).show();
}
// Click “Preview” to run your code
});