I need to access a SPAN tag with in every DIV tag
so i used this following code
$("DIV").click(function(){
$(this + "SPAN").show();
});
Is the above code is correct? Its not working for me! Its showing nothing too..
Please help me
Thanks,
Praveen J
You can use
.find()for getting an element inside another, like this: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:
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:You can give it a try here