Adrienne
Adrienne

Reputation: 2680

How do you concat a string to a div class name?

For example, <div class="hi_" + "1"> (which doesn't work)

Use case is if I'm templating in handlebars and my code is:

{{#each this}}
     <div class="box_" + {{id}}>
{{/each}}

How would I go about naming my divs?

Upvotes: 2

Views: 5358

Answers (1)

Jon Rubins
Jon Rubins

Reputation: 4413

You can simply insert the placeholder into the class attribute like so:

{{#each this}}
    <div class="box_{{ id }}"></div>
{{/each}}

Upvotes: 1

Related Questions