views:

21

answers:

1

I have a nested tree. Under each <li> tag I have a string value and an integer value. Which way is more efficient: storing them inside <li> options, say integer under "id" option and string under "title", or storing them in a hidden <input> values under each <li>

I'm using jQuery to find elements in a DOM now, but I'll gladly accept more profitable way, if such exists in native JavaScript.

A: 

Try seperating the values into different span classes with semantic class names. You can then use jquery to retrieve the data like

var intVal = $('li span.int-value').text()

And why is this better than `var intVal = $('li input.int\string').val()`?
Chaotic_one