I'm creating a list with jquery
$('<li value="0" onclick="'if(cond){ }'"> </li>).appendTo('#ul list');
The problem is in the section onclick, can someone tell me the right syntax?
Since you use jQuery, then don't use the onclick attribute.
$('<li>').attr('value', '0').click(function() {
if (cond) {
//...
}
}).appendTo('#ul list');
list references. I think he wants $('#list') and is confused about the # symbol. I think he wants the UL named LIST.
lihas not a value attribute.valueattribute, i.e. the HTML standard doesn't define such an attribute for LI elements.