Skip to content

Instantly share code, notes, and snippets.

@townivan
Created October 6, 2020 20:18
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 townivan/70195464a6335dae4468fcb0ec4a45c2 to your computer and use it in GitHub Desktop.
Save townivan/70195464a6335dae4468fcb0ec4a45c2 to your computer and use it in GitHub Desktop.
a function to set an attribute with JavaScript
function sestAttrib(el_id, el_attr, el_value){
if (document.getElementById(el_id)){ // if element exists
document.getElementById(el_id)[el_attr] = el_value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment