JSFiddle - React, Tailwind, and code Playground
HTML
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Hello World</title>
</head>
<body>
<div id="container"></div>
<input type="text" size="30" name="display" id="display" />
<input type="button" id="showVal" value="Value Property" />
<input type="button" id="showTxt" value="selectedIndex/Text" />
<br>
</body>
</html>
JavaScript
$(document).ready(function(){
var url = "https://api.myjson.com/bins/cujwe";
$.getJSON(url, function(json) {
var select = $("<select></select>").attr("id", "menuselect").attr("name", "image");
$.each(json,function(index,json){
select.append($("<option></option>").attr("value", json.image).text(json.variete));
});
$("#container").html(select); //fin de la generation du menu html select
var sel = document.getElementById('menuselect'); //test pour retour visuel
var el = document.getElementById('display');//test pour retour visuel
document.getElementById('showVal').onclick = function () {//test pour retour visuel
el.value = sel.value;//test pour retour visuel
fonction_post_click();//test pour retour visuel
}//test pour retour visuel
document.getElementById('showTxt').onclick = function () {//test pour retour visuel
el.value = sel.options[sel.selectedIndex].text;//test pour retour visuel
}//test pour retour visuel
});
});
function fonction_post_click(){
var selection = document.getElementById('menuselect'); //je recupere le click
alert(selection)// mais maintenant je souhaiterais par exemple avoir la donnée 'rayon' mais JE BLOQUE ??
}