Javascript 按ID的JS IF语句

Javascript 按ID的JS IF语句,javascript,Javascript,我在我的网站上有实时聊天的开放时间,每个开放时间都有自己的ID数据聊天类别。有一个类别ID我想针对不同的开放时间。我正在努力编写一个以这个ID为目标的IF语句。我已经提取出需要编辑的JS 以下是ID为的HTML: <div class="live_chat" data-chat-interface="toms" data-chat-category="407" data-chat-product="370"></div> 这是我无法正确理解的一点,也需要添加IF语句:

我在我的网站上有实时聊天的开放时间,每个开放时间都有自己的ID数据聊天类别。有一个类别ID我想针对不同的开放时间。我正在努力编写一个以这个ID为目标的IF语句。我已经提取出需要编辑的JS

以下是ID为的HTML:

<div class="live_chat" data-chat-interface="toms" data-chat-category="407" data-chat-product="370"></div>
这是我无法正确理解的一点,也需要添加IF语句:

// Show correct opening times for all iChatCategorys except 407
var sOpeningTimes = (sChatInterface.indexOf("toms") >= 0) ? 'Live chat is open Monday to Thursday from 8:30am to 5:30pm, Friday 8:30am to 5pm.' : 'Live chat is open Monday to Friday from 8am to 8pm, Saturday 8am to 6pm.';

// Show correct opening times for iChatCategorys 407 only goes under here?

只需编辑三元中的条件

// Show correct opening times for all iChatCategorys except 407
var sOpeningTimes = (iChatCategory != 407) ? 'Live chat is open Monday to Thursday from 8:30am to 5:30pm, Friday 8:30am to 5pm.' : 'Live chat is open Monday to Friday from 8am to 8pm, Saturday 8am to 6pm.';

如果ichatcategory==407{设置特殊小时数}或者{设置标准小时数}?到底是什么问题?你有错误吗?
// Show correct opening times for all iChatCategorys except 407
var sOpeningTimes = (iChatCategory != 407) ? 'Live chat is open Monday to Thursday from 8:30am to 5:30pm, Friday 8:30am to 5pm.' : 'Live chat is open Monday to Friday from 8am to 8pm, Saturday 8am to 6pm.';
 var sOpeningTimes = "";
 if(iChatCategory !== "407") {
 sOpeningTimes = (sChatInterface.indexOf("toms") >= 0) ? 'Live chat is open Monday to Thursday from 8:30am to 5:30pm, Friday 8:30am to 5pm.' : 'Live chat is open Monday to Friday from 8am to 8pm, Saturday 8am to 6pm.';

 } else {
  sOpeningTimes = "message for iChatCategory 407";
 }