I have the following (broken) code:
$(".old_post").hover(function(){
$(this > ".post_right_nav").show();
post _ right _ nav is a div(containing other divs) that holds some controls for the user to press. I'd like to only show these controls when the user is hovering over a post. How can I properly select the child element of every post?
You can use context, the following is saying: Search for the elements that have class='post-right-nav' within the context of this
$(".old_post").hover(function(){
$(".post_right_nav", this).show();
...
That will get you all descendants, if you want just the children you could do the following
$(".old_post").hover(function(){
$(this).children(".post_right_nav").show();
...
I found a quick article that goes over the use of context in the jQuery selector
http://beardscratchers.com/journal/jquery-its-all-about-context
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.