Tuesday, May 27, 2014

Hide first element of tag using jquery

1) <script>
$(document).ready(function(){
  $("button").click(function(){
    $("p:first").hide();
  });
});
</script>

2) <h2>This is a heading</h2>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<button>Click me</button>

3) Selects the first <p> element

No comments:

Post a Comment