0
비슷한 요소가 두 개 있는데 각 값을 가져와야합니다. 이 둘의 유일한 차이점은 차별화 된 수업입니다.요소에서 속성 가져 오기
TypeError: $(...).hasClass(...).attr is not a function.
내가 무엇을 놓치고 :
<div id="box_1231231" class="myItem boxItem"></div>
<div id="toy_1231231" class="myItem toyItem"></div>
$(document).delegate('.myItem', 'mouseup', function() {
var key_box = ($(this).hasClass('.boxItem').attr('id')).replace('box_', ''),
val_box = $(this).hasClass('.boxItem').val(),
val_toy = $(this).hasClass('.toyItem').val();
...
});
나는 다음과 같은 오류가 계속?
$(this).hasClass('toyItem')
$(this).hasClass('boxItem')
'hasClass'는'attr' 메소드가없는 부울 값을 반환합니다. 나는 당신이 여기서 어떤 논리를 기대하는지 모르겠습니다. –
'($ (this) .hasClass ('. boxItem'). attr ('id'))'주위의 괄호가 왜? div에는 값 속성이 없습니다. – j08691
$ (this) .hasClass ('boxItem')을 시도하십시오. –