Code Snippet - How to Add CSS Class to Jade


condition for adding css class to html in Jade.

Example Code

append css class active when variable is equal to 1. The variable data.Valueis coming from node.js server side.

input(type='submit' value='button' class="btn btn-link" name="number")(class= data.Value === 1 ? "active" : "")

The Html Code

The actual html code will generate like following.

input class="btn btn-link active" name="pageNumber" type="submit" value="1"