2017-08-07 68 views

回答

0

您無法使用JavaScript來實現PHP,因此您需要使用JavaScript編寫解決方案。

爲簡單起見使用jQuery。

const listEl = $('.my-class'); 
if (myBooleanJavaScriptVariable) { 
    listEl.addClass('another-class'); 
} 

取決於myBooleanJavaScriptVariable收到它的值可能會改變你的方法。儘管我們需要更多關於這個腳本的細節。