Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jade - create multiple html elements

Tags:

html

css

class

pug

I want to create multiple elements having the same class with jade. Is this possible? It should be something like this:

3 times do
  insert div.className

Thank you in advance!

like image 948
wonderbummer Avatar asked May 10 '26 20:05

wonderbummer


1 Answers

Multiple elements can share a single class without issue, just as in standard HTML. That's one of the underlying differences between a class and ID, though there is some other differentiation.

An easy way to do this is using a traditional JavaScript for-loop incorporated into your Jade template.

- for(var x = 0;X < 3;x++) .nameOfClass

or (obviously)

- for(var x = 1;x <= 3;x++) .nameOfClass

like image 127
Tejas Manohar Avatar answered May 12 '26 11:05

Tejas Manohar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!