-
jQuery로 form id, class, name 의 value 조회jQuery 2019. 5. 13. 21:56
jQuery를 이용한 id, class, name 별로 input value값 가져오기.
<div class="test_class" id="test_id" name="test_name"></div>
//1. By id var name_by_id = $('#test_id').attr('name'); var class_by_id = $('#test_id').attr('class'); console.log(name_by_id); console.log(class_by_id); //2. By class var name_by_class = $('.test_class').attr('name'); var id_by_class = $('.test_class').attr('id'); console.log(name_by_class); console.log(id_by_class); //3. By name var id_by_name = $('[name="test_name"]').attr('id'); var class_by_name = $('[name="test_name"]').attr('class'); console.log(id_by_name); console.log(class_by_name);