Skip to content

Instantly share code, notes, and snippets.

@panych
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save panych/12c342c429088f425430 to your computer and use it in GitHub Desktop.
Save panych/12c342c429088f425430 to your computer and use it in GitHub Desktop.
Get options of select element as JSON
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;
}
@panych
Copy link
Author

panych commented May 4, 2015

Если все данные сразу хтмл, то еще проще.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment