I create a variable from a html object
var li = $(this).closest('li');
How do I now select inner html objects from this variable eg span. I have tried
li.span
but no luck.
You can use context to pass the variable with selector. You can learn more about selector and context here
var li = $(this).closest('li');
$('span', li)
htmlOfFirstSpan = $('span', li).html();
This will give you span elements within li
This should work:
var li = $(this).closest('li');
$(li).innerHtml();
You could also do:
$(li).('span').html();
$(li).('.someClass').html();