You can use .find()
for getting an element inside another, like this:
$("div").click(function(){
$(this).find("span").show();
});
As a general rule, to get anything relative to this
, you're typically going to start with $(this)
and some combination of the tree traversal functions to move around.
For actual code, based on comments below:
If your code looks like this:
<fieldset>
<legend>Link</legend>
<span>CHECK</span>
</fieldset>
Then .find()
won't work since on $("legend")
selector because the <span>
isn't inside the <legend>
it's a sibling, so use .siblings()
(optionally with a selector) like this:
$("legend").click(function(){
$(this).siblings("span").show();
});
You can give it a try here