如何获取前端input标签的id
前端可以通过以下方式获取input标签的id:
- 使用JavaScript的getElementById方法:
var input = document.getElementById('inputId');
var id = input.id;
console.log(id);
- 使用jQuery的attr方法:
var id = $('#inputId').attr('id');
console.log(id);
其中,'inputId'为input标签的id属性值。
原文地址: https://www.cveoy.top/t/topic/padC 著作权归作者所有。请勿转载和采集!