Skip to content

Instantly share code, notes, and snippets.

@thejungwon
Last active March 10, 2019 18:25
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 thejungwon/530632e21e12aaa86c4511ac96f5bbed to your computer and use it in GitHub Desktop.
Save thejungwon/530632e21e12aaa86c4511ac96f5bbed to your computer and use it in GitHub Desktop.
//1. By id
var name_by_id = $('#test_id').attr('name');
var class_by_id = $('#test_id').attr('class');
//2. By class
var name_by_class = $('.test_class').attr('name');
var id_by_class = $('.test_class').attr('id');
//3. By name
var id_by_name = $('[name="test_name"]').attr('id');
var class_by_name = $('[name="test_name"]').attr('class');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment