Akshata
Akshata

Reputation: 11

Concatenate two appended values in from two jQuery objects

I have the following two lines of code which gives me two values, one in miles and the other in km. i want to concatenate both of them and display in the same column separated by '/'. How will i gain it?

@$el.append @odometerColumn2.render().$el
@$el.append @odometerColumn3.render().$el

Upvotes: 0

Views: 37

Answers (1)

T J
T J

Reputation: 43156

Assuming odometerColumn views contain text nodes, you could do something like:

var htmlString = @odometerColumn2.render().$el.text().concat('/', @odometerColumn3.render().$el.text() );
@$el.append(htmlString);

If they contain actual HTML you can do the same with html() instead of text()

Upvotes: 1

Related Questions