multiple class attribute

227 views
Skip to first unread message

Pavel Martynov

unread,
Oct 25, 2011, 5:23:35 PM10/25/11
to Embedded JavaScript
is it possible to assign multiple classes to className attribute with
EJS?

i'd like to get this:
<div class="class1 class2">

i try this:
<% var class1 = "class1"; %>
<% var class2 = "class2"; %>
<div class=<%= class1 + ' ' + class2 %>>

but this comes out:
<div class="class1" class2>

Brian Moschel

unread,
Oct 25, 2011, 5:28:45 PM10/25/11
to embeddedj...@googlegroups.com
Please post to http://forum.javascriptmvc.com/#home


--
You received this message because you are subscribed to the Google Groups "Embedded JavaScript" group.
To post to this group, send email to embeddedj...@googlegroups.com.
To unsubscribe from this group, send email to embeddedjavascr...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/embeddedjavascript?hl=en.


Justin Meyer

unread,
Oct 25, 2011, 5:51:31 PM10/25/11
to embeddedj...@googlegroups.com, Embedded JavaScript
You need quotes around your class=""

Sent from my iPhone

Pavel Martynov

unread,
Oct 25, 2011, 6:17:56 PM10/25/11
to Embedded JavaScript
you mean this?
<div class=<%= ' " ' + class1 + ' ' + class2 + ' " ' %>>
the result is
<div class=""" class1 class2 &#34;>
still incorrect

Pavel Martynov

unread,
Oct 25, 2011, 6:21:22 PM10/25/11
to Embedded JavaScript

got it! that's right
<div class="<%= class1 + ' ' + class2 %>>"
works correctly
thanks
Reply all
Reply to author
Forward
0 new messages