使用jquery元素的foreach

ktm*_*ktm 1 jquery

我想在点击按钮时显示每个"p"元素.但它不是没有工作,请帮助.

<script>
$(document).ready(function(){
$("p").hide();
    $("button").click(function(){
            $('p').each(function() {
                //alert($(this).text());
               var abc = $(this).text();
              abc.next().show();
              });
    });     
});
</script>


<button>Toggle</button>
<p>Hello</p>
<p>Good morning</p>
<p>Good after noon</p>
<p>Good evening</p>
<p>Good night</p>

<div></div>
Run Code Online (Sandbox Code Playgroud)

Rus*_*sak 7

$("p").hide();

$("button").click(function(){
    $('p').each(function () {
        if (!$(this).is(":visible")) {
            $(this).show();
            return false;
        }
    });
});
Run Code Online (Sandbox Code Playgroud)