2014-03-29 1 views
0

속성에 대해 특정 값을 갖는 모든 요소의 클래스 또는 ID 이름을 가져 오는 방법이 있습니까?특정 속성 값을 기반으로 요소의 클래스 또는 ID 이름 얻기

<rect class="rect0" x="45" y="0px" width="40px" height="40px" fill="#ff0000" selected="0"></rect> 
<rect class="rect1" x="90" y="0px" width="40px" height="40px" fill="#ff0000" selected="0"></rect> 
<rect class="rect2" x="135" y="0px" width="40px" height="40px" fill="#ff0000" selected="0"></rect> 
<rect class="rect3" x="180" y="0px" width="40px" height="40px" fill="#0400fb" selected="1"></rect> 
<rect class="rect4" x="225" y="0px" width="40px" height="40px" fill="#ff0000" selected="0"></rect> 
<rect class="rect5" x="270" y="0px" width="40px" height="40px" fill="#0400fb" selected="1"></rect> 
<rect class="rect6" x="315" y="0px" width="40px" height="40px" fill="#fb0004" selected="0"></rect> 

내가 선택한 속성이 경우 rect3에서 1의 값을 가지며, rect5이 반환하는 모든 사각형의 클래스 이름을 얻으려면 : 예를 들어, 나는 다음과 같은 경우.

+0

.map() 당신이 몇 가지 코드를 작성 실제로 해봤 사용할 수 있습니까? –

답변

관련 문제