如何在javaScript中获得知道类名的属性

如何在javaScript中获得知道类名的属性,javascript,html,Javascript,Html,我想得到元素的Id或其他属性,我知道它的类名 var removeBtns=document.getElementsByClassName(“fa-fa-times-circle-floatright-fa-fw-js-model-large-notfirst”); 对于(i=0;i

我想得到元素的Id或其他属性,我知道它的类名

var removeBtns=document.getElementsByClassName(“fa-fa-times-circle-floatright-fa-fw-js-model-large-notfirst”);
对于(i=0;i
使用
.getAttribute(“tasknr”)
作为类名或id,它将是工作的

var removeBtns=document.getElementsByClassName(“fa-fa-times-circle-floatright-fa-fw-js-model-large-notfirst”);
对于(i=0;i
使用
.getAttribute(“tasknr”)
作为类名或id,它将是工作的

var removeBtns=document.getElementsByClassName(“fa-fa-times-circle-floatright-fa-fw-js-model-large-notfirst”);
对于(i=0;i

使用
removeBtns[i].getAttribute('id')
应该work@Roy您错了,它将与
.id
一起工作您提供的代码可以工作。问题一定出在其他地方。等待您想要的
tasknr1
!使用
removeBtns[i]对我来说似乎毫无意义。getAttribute('id')
应该work@Roy您错了,它将与
.id
一起工作您提供的代码可以工作。问题一定出在其他地方。等待您想要的
tasknr1
!这对我来说似乎毫无意义