This id
1 2 3 |
var thisid = $(this).attr("id"); |
This first one gets the id of the closest li
1 2 3 |
var thetext = $(this).closest("li").attr("id"); |
This will start from where clicked, and go up to the first .mybutton, then find .fakes class inside.
1 2 3 |
var thetext = $(this).closest('.mybutton').find(".fakes").html(); |
Get the image url value from class name
1 2 3 |
var thetext = $(this).closest('.deleteitem').find(".item").attr('src'); |
Get the image name/src/alt tag from an image inside a class
1 2 3 4 5 |
<div class="dz-image"> <img src="realP1080317.JPG" alt="P1080317.JPG"> </div> |
1 2 3 4 |
var dog = $( '.dz-image > img' ).attr( 'alt' ); alert(dog); |
Hides the closest element with the classname .deleteitem
1 2 3 |
$(this).closest('.deleteitem').hide(); |
Affect the opacity of an image
1 2 3 |
$(this).closest('.deleteitem').css({"opacity":"0.4"}); |
This snippet will find the clicked elements – next elements class called “.item” and get the src the image with that class name!
1 2 3 4 |
theimagename = $(this).next().find('.item').attr('src'); alert(theimagename); |
Get ID of next DIV up
1 2 3 4 |
var id = $(".button").closest("div").prop("id"); alert(id); |