개발! 딱 깔끔하고 센스있게!

제이쿼리 this 간단 예제 본문

HTML, CSS, Jquery 메모

제이쿼리 this 간단 예제

렉사이 2018. 10. 25. 12:43


제이쿼리 this 간단 예제


<div onclick="test(this)" val='good'>

[제이쿼리]

</div>


<div id="test2" val='wow'>

[제이쿼리2]

</div>



<script>

//함수

function test(go)

{

alert($(go).attr("val"));

}


//$(document).ready

$(function(){

$("#test2").click(function () {


alert($(this).attr('val'));


$(this).html('zzzzzzzzz');


$(this).css('background-color','red');

});

});



//선택자 예제

//$(this)

//$("div:first")

//$("ul li:first")

//$("ul li:first-child")

//$("div#test .go")

</script>

Comments