The parameter ui
has a property called selected
which is a reference to the selected dom element, you can call innerHTML
on that element.
Your code $('.ui-selected').innerHTML
tries to return the innerHTML
property of a jQuery wrapper element for a dom element with class ui-selected
$(function () {
$("#select-image").selectable({
selected: function (event, ui) {
var $variable = ui.selected.innerHTML; // or $(ui.selected).html()
console.log($variable);
}
});
});
Demo: Fiddle