jQuery mouseup 클릭한 id값 가져오기
가져오는 것은 일반적으로 아래 형태 많이 사용 합니다.
event.currentTarget.id
가져오기. 변경하기
.attr( attributeName ) // 가져오기
.attr( attributeName , 변경할값 ) // 변경하기
클릭한 아이디
var click_id = $(this).attr('id');
부모 아이디 얻기
$(this).closest('div').attr('id')
변경하는방법
$( '#test' ).attr( 'value', 'Hello' );
$('#test1')
.mouseup(function(event)
{
console.log('jquery mouse up: ', event.pageY);
})
.mousedown(function(event)
{
var idname = event.currentTarget.id;
console.log('클릭한 id값: ', $(this).attr('id') );
console.log('클릭한 id의 data값: ', $(this).attr('data-name') );
});
해당하는 부분의 다른 속성값을 가져오는 것도 문제 없습니다.
관련링크