Capture the HTML of a SELECT, which uses the editableSelect Plugin

0

I have the following code:

$("#idSelect").editableSelect({
    effects: 'fade',
    duration: 'fast'
});

To take the value, I realize:

$("#idSelect").val(); // Funciona bien!

Now I want to take the HTML of the select (all OPTION):

 $("#idSelect").html(); // Pero esto no funciona
    
asked by Islam Linarez 07.10.2017 в 23:36
source

1 answer

1

I would have to use siblings () to find Sibling elements in DOM since the plugin creates a list with the class es-list .

$(function() {
    $("#idSelect").editableSelect({
        effects: 'fade',
        duration: 'fast'
    });
    var items = $('#idSelect').siblings('.es-list').find('li');
    $(items).each(function(index, el) {
        console.log($(el).text());
    });
});
<link href="https://rawgithub.com/indrimuska/jquery-editable-select/master/dist/jquery-editable-select.min.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://rawgithub.com/indrimuska/jquery-editable-select/master/dist/jquery-editable-select.min.js"></script>

<select id="idSelect">
    <option value="1">Uno</option>
    <option value="2">Dos</option>
    <option value="3">Tres</option>
</select>
    
answered by 08.10.2017 / 00:36
source