简体   繁体   中英

I've many parent elements with class news how can i select children on one from other children in same parent

i want to set display of class .change from class .cha in the current class .news

 $(function () {

        $('.cha').click(function(){
            $(this).parent().find('.change').css('display','inline');
            });
});

 jQuery(document).ready(function($){ $('.button').click(function(){ $('ul li:nth-child(3)').addClass('red'); }); }); 
 .red{ background:red; } 
 <!DOCTYPE html> <html lang=""> <head> <link rel="stylesheet" href="https://cdn.rawgit.com/twbs/bootstrap/v4-dev/dist/css/bootstrap.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> </head> <body> <ul> <li>item1</li> <li>item2</li> <li>item3</li> <li>item4</li> </ul> <a href="#" class="button">Select</a> <!-- jQuery --> </body> </html> 

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM