二元运算放在class里不正确,
应该怎么写才正确
(item.is_supported != 0)? text-danger : item.support_count;
html+= '<p id="like_' + item.id + '" class="col-xs-4" onclick="tones();like(' + item.id + ')"><p style="font-size: 16px;" class="iconfont icon-likefill inline animated ' + (item.is_supported != 0)? text-danger : item.support_count; + '">' + [i] + '</p></p>';
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
分开来写,不容易出错
把
item.support_count
后面那个分号删掉。分号不是
? :
运算符的一部分。分号的意思是结束一个语句。