Pages

JQuery select the clicked class

Here is a JQuery code snippet  to get the clicked div elements's attribute or the value with the similar class names on click function

<script>

$(document).ready(function(){
    $('.simg').click(function(){
        //var pth = $('.simg').attr('src');
        
        var pth = $(this).attr('src');
        
        console.log(pth);
    });    
});

</script>

JQuery select the clicked class

No comments:

Post a Comment

Search This Blog