selector - Child of a parent of $(this) in jQuery -
i have following html:
<div class="container"> <img class="imgtab" src="http://cloudsmaker.com/hipsterwall/img/salto-al-norte.jpg"> <p class="textab">paragraph text</p> </div>
with following javascript:
$(document).ready(function () { //initial conditions $(".container > img").width("200px"); $(".container > img").height("116px"); $(".container > p").hide(); //on click $(".container > img").toggle(function () { //fired first time $(this).animate({ width: "400px", height: "232px" }); //$(**selectorneeded**).show();//this need show text }, function () { // fired second time $(this).animate({ width: "200px", height: "116px" }); //$(**selectorneeded**).hide();//this need hide text again }); });
the idea user clicks on image, expands 200x116px 400x232px , block of text appears below enlarged image. text disappears when image clicked again , image reverts smaller state.
i need able refer text within div able hide , show it.
i using more 1 of these images on same pages need able use this
selector refer text under image has been clicked , not text under other images.
when click on image though this
selector becomes image rather div cant refer
child of div. selector can use around this?
here jsfiddle if helps: http://jsfiddle.net/edddotcom/um5ct/
$(this).next(".textab").hide();
comments have suggested .siblings()
, since know text below image, .next()
seems more appropriate.
Comments
Post a Comment