JSFiddle - React, Tailwind, and code Playground

/* http://stackoverflow.com/questions/23121728/using-jquery-to-get-unknown-data-attributes-and-copy-them-to-new-element# */

by Paul Smith

HTML

<ul class="selections">
    <select>
        <option data-somedata="something" data-else="something else" value="some value">abc</option>
        <option data-somedata="something other" data-else="something else other" value="some value">def</option>
    </select>
</ul>

JavaScript

function optdata( selector, container, el ) {
    $.each( $(selector), function ( index, data-else ) {
        $(container).append(
        $(el).html( "<a href=''>" + $(data-else).html() + "</a>" )
            .data( $(value).data()) 
        );
        return ( index != $(value).size() )
    });
};
optdata( $("option"), $(".selections"), "<li>" );

 console.log( $("option:first").data()                                        ,$("option:last").data(), $("li:first").data()                                      ,$("li:last").data() );