Can there be more than one class added after template.js is judged according to the value in jquery?

<%=item.type==2?"class="type-radio js-type-radio type-select"" : "class="type-radio js-type-radio""%>

is it okay to have more than one class name type-radio js-type-radio type-select after such a judgment? Finally, on html, it feels like only the first class name has been added

.
Mar.12,2021

type-radio js-type-radio these two duplicates, write dead is good, judge that the extra, either add, or is "


OK
when you execute this ternary operator again, it is the environment where the template engine works, the template engine does not know the class name, it only knows that you are the value of a string with spaces, so there is no problem.

<%=item.type==2?'class="type-radio js-type-radio type-select"' : 'class="type-radio js-type-radio"'%>

your line of code is an evaluation expression. Eventually, a string such as
type = = 2 = = > class= "type-radio js-type-radio type-select"
type! = 2 = > class= "type-radio js-type-radio"
can be parsed by the browser

as an attribute of the tag.
Menu