Javascript 只想在<;中显示第一个类;部门>;使用Jquery

Javascript 只想在<;中显示第一个类;部门>;使用Jquery,javascript,jquery,html,css,Javascript,Jquery,Html,Css,嗨,我只想在类ProductPriceRating中显示第一个div test,我想隐藏其余的div。有人能帮我吗 47.00美元 您第一次错过了。测试,您的代码将被删除 $(文档).ready(函数(){ $('.ProductPriceRating.test:类型的第一个').addClass('active'); }) .test{ 显示:无; } .test.active{ 显示:块; } 47.00美元 您第一次错过了。测试,您的代码将被删除 $(文档).ready(函数()

嗨,我只想在类ProductPriceRating中显示第一个div test,我想隐藏其余的div。有人能帮我吗


47.00美元
您第一次错过了
。测试
,您的代码将被删除

$(文档).ready(函数(){
$('.ProductPriceRating.test:类型的第一个').addClass('active');
})
.test{
显示:无;
}
.test.active{
显示:块;
}

47.00美元
您第一次错过了
。测试
,您的代码将被删除

$(文档).ready(函数(){
$('.ProductPriceRating.test:类型的第一个').addClass('active');
})
.test{
显示:无;
}
.test.active{
显示:块;
}

47.00美元

.test{显示:无;}
.测试:第n个孩子(2){
显示:块!重要;
}
47.00美元


.test{显示:无;}
.测试:第n个孩子(2){
显示:块!重要;
}
47.00美元


您尝试过的内容应该与
$('.ProductPriceRating.test')一样简单。而不是(':first').hide()
$('.btn')。不是(':first').hide()
您尝试过的内容应该与
$('.ProductPriceRating.test')一样简单。不是(':first').hide()
$('.btn')。不(':first').hide()
不需要使用任何时髦的库它是可以实现的请使用这个主题在jquery中询问初学者:-)因为我可以看到他没有提到jquery的名称:)他只是想通过css实现一些很容易实现的东西,为什么要添加一个大库来实现呢?不需要使用任何时髦的库,这是可以实现的。请使用jquery中提出的这个主题:-)因为我可以看到他没有提到jquery的名称:)他只是想通过css实现一些很容易实现的东西,为什么要添加一个大库来实现呢
<html>
  <head>
    <title></title>
    <style type="text/css">
    .test{display:none;}
    .test:nth-child(2) {
       display: block !important;
     }
</style>
 </head>
 <body>
<div class="ProductPriceRating">
        <strong>$47.00</strong>

        <div class="test"><input type="button" class="btn" id="hello_123" onclick="window.open('1234')" value="test.com"></div>
        <div class="test"><input type="button" class="btn" id="hello_123" onclick="window.open('1234')" value="test.com"></div>
        <div class="test"><input type="button" class="btn" id="hello_123" onclick="window.open('1234')" value="test.com"></div>
        <div class="test"><input type="button" class="btn" id="hello_123" onclick="window.open('1234')" value="test.com"></div>
        <div class="test"><input type="button" class="btn" id="hello_123" onclick="window.open('1234')" value="test.com"></div>