Last active
August 29, 2015 14:20
-
-
Save panych/12c342c429088f425430 to your computer and use it in GitHub Desktop.
Get options of select element as JSON
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var selectOptionsAsJSON = function(selectEl) { | |
var result = [], options = selectEl.options; | |
for (var i=0; i < options.length; i++) { | |
result.push({"text":options[i].text, "value":options[i].value}); | |
} | |
window.prompt('Done. Copy text:', JSON.stringify(result)); | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Если все данные сразу хтмл, то еще проще.