Jade checkbox checked attribute unchecked based on conditional (if)

牧云@^-^@ 提交于 2019-11-30 01:42:57

You can use:

input(type="checkbox", name="completed", checked=(true===false ? "checked" : undefined))

No need to specify the values:

input(type="checkbox", name="completed", checked=(condition))

If condition is false, there is no checked attribute will added.

Another way to do the same thing is by 'if' condition:

if(#{data.refrigerated} == '1')
   input(type='checkbox', name='refrigerated', checked)
else
   input(type='checkbox', name='refrigerated')

When condition will be true, You will get checked checkbox on DOM otherwise you will get unchecked checkbox.

you can try like this

  option(value='man' selected = profile.sex ==='man') man
  option(value='female' selected = profile.sex ==='female') female
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!