Select all p elements inside a div in jQuery
Description
The following code shows how to select all p elements inside a div.
Example
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){<!-- ww w.ja v a2s . co m-->
$("div > p").css("border", "1px solid gray");
});
</script>
</head>
<body>
<div><p>java 2s.com</p></div>
</body>
</html>
The code above generates the following result.
...
Select Form File upload $(":file") in jQuer...
Select Form Image button with Form Image bu...
Select Form Password field with Form Passwo...
Select Form Radio button with Form Radio bu...
Select Form Reset button $(":reset") in jQu...
Select Form Selected option element $("sele...
Select Form Submit button with Form Submit ...
Select Form button $(":button") in jQuery
Select Form text fields with form text fiel...
Select Header element with header element s...
Select LI list element by index in jQuery
Select all LI elements for a UL element and...
Select all div tags $("div") in jQuery
Select all elements that are the first chil...
Select all elements that are the last child...
Select all elements that are the nth-child ...
Select all elements that are the only child...
Select all elements under a certain element...
Select all the divs before the last and giv...
Select an element by element name and its i...
Select based on text content with Contains ...
Select by check child element with has meth...
Select current and next element in jQuery
Select current element with $(this) selecto...
Select div element with paragraph inside $(...
Select div parent elements of each span in ...
Select element by Combining first selector ...
Select element by checking if if the specif...
Select element by class name in jQuery
Select elements by tag name $("div") in jQu...
Select elements with id attribute in jQuery
Select empty table cell in jQuery
Select even numbered child in jQuery
Select event table row with Even element se...
Select first paragraph with first selector ...
Select first paragraph with given class in ...
...
Select Form File upload $(":file") in jQuer...
Select Form Image button with Form Image bu...
Select Form Password field with Form Passwo...
Select Form Radio button with Form Radio bu...
Select Form Reset button $(":reset") in jQu...
Select Form Selected option element $("sele...
Select Form Submit button with Form Submit ...
Select Form button $(":button") in jQuery
Select Form text fields with form text fiel...
Select Header element with header element s...
Select LI list element by index in jQuery
Select all LI elements for a UL element and...
Select all div tags $("div") in jQuery
Select all elements that are the first chil...
Select all elements that are the last child...
Select all elements that are the nth-child ...
Select all elements that are the only child...
Select all elements under a certain element...
Select all p elements inside a div in jQuer...
Select all previous tags and set styles in ...Select all the divs before the last and giv...
Select an element by element name and its i...
Select based on text content with Contains ...
Select by check child element with has meth...
Select current and next element in jQuery
Select current element with $(this) selecto...
Select div element with paragraph inside $(...
Select div parent elements of each span in ...
Select element by Combining first selector ...
Select element by checking if if the specif...
Select element by class name in jQuery
Select elements by tag name $("div") in jQu...
Select elements with id attribute in jQuery
Select empty table cell in jQuery
Select even numbered child in jQuery
Select event table row with Even element se...
Select first paragraph with first selector ...
Select first paragraph with given class in ...
...