我使用了一个while循环,在这个循环中,我取了一个,然后单击一个button.when,这个按钮只显示一个按钮。这是我的代码--
<script type="text/javascript" src="js1/jquery-2.2.3.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".bb").each(function(){
$(this).click(function(){
$('.aa').each(function(){
$('.aa').toggle("fast");
});
});
});
});
</script>
</head>
<body>
<?php
$c = 0;
while($c <10)
{
$c++;?>
<button class="bb" >x</button>
<div class="aa" style="display:none;"><input type="text" value="<?php echo $c;?> " class="t1" />
</div>
<?php }
?>发布于 2016-05-14 15:26:52
我所理解的是你想要在点击按钮之后切换锚点。如果是,您的jQuery应该是这样的
$(".bb").click(function() {
$(this).nextAll(".aa").first().css("display", "block");
});发布于 2016-05-14 15:31:15
试试这个:
它将只显示被单击按钮的div,并隐藏其他按钮。
$(".bb").click(function() {
$(".aa").hide() // hide all div
$(this).next(".aa").css("display", "block"); // it will display only one div whose previous button is clicked
});https://stackoverflow.com/questions/37223834
复制相似问题