Working with Selctors: setters and getters
Hello again, still working on the jQuery basics tutorial. So I'm at the setters and getters sections and the documentation states:
Setters affect all elements in a selection ---ok got it..then it goes on to say:
whereas getters return the requested value only for the first element in the selection -- in my html I added three <p> tags and when i used:
$("p").html() all three <p> tags were returned. I was under the impression from the documentation that only the first one was supposed to be returned and I should have expected to see all three tags if I had used
.text(). Was wondering if someone could please clarify this for me.
Thanks in advance for your help!!
- I'm copying my html:
- <h3>Second getter and setter test</h3>
<p>This is a wonderful journey</p>
<p>I want a margarita</p>
<p>I want to go to sleep</p>
<script src="jquery.js"></script>
<script>
$( document ).ready(function() {
$( 'a' ).click(function(event) {
event.preventDefault();
$( this ).hide( "slow" );
$('p').fadeIn(2000);
$("h2").html("New h2");
$("h3").html("The age of aquarius");
$("p").html();
});
});
</script>