I’m trying to teach myself basic html with JavaScript using the Jquery library. With the code below I'm trying to change the p tags within the div red and the other p tags outside of the div yellow. The code below changes all the p tags yellow but when I place 4. above 3. it works. Just need a simple explanation why and also this is the html code http://imageshack.us/photo/my-images/29/k9do.jpg/
$(document).ready(function() {
$("#testbutton").click(function() {
$("div p").css("background-color" , "red");
$("p").css("background-color" , "yellow");
});
});