새소식

Front

[ul-li tag] jquery li click event

  • -
728x90


 solution 1 : 

<script>
    jQuery(document).ready(function() {
        $("#test li").on("click", function() {
            alert($(this).text());
        });
    });
</script>


OR


※ solution 2 :

<script>
    jQuery(document).ready(function() {
        $("#test").on("click", "li", function() {
alert($(this).text()); }); });
</script>


thanks~!


reference :

https://stackoverflow.com/questions/6365255/jquery-onclick-event-for-li-tags

https://stackoverflow.com/questions/16707318/jquery-how-get-value-ul-when-click-on-li

반응형
Contents

포스팅 주소를 복사했습니다

이 글이 도움이 되었다면 공감 부탁드립니다.