Use text() to get text without child element

jQuery.fn.justtext = function() {
    return $(this)  .clone()
            .children()
            .remove()
            .end()
            .text();
};

Source:
http://viralpatel.net/blogs/jquery-get-text-element-without-child-element/

 

My Version:

selected_name: function(){
var $this = $(this);
var $li = $this.find(‘a.selected’).parent(‘li’);
var $text = $li.clone().children().remove();

return $text.text();