jQuery – :parent Selector

The jQuery parent selector select all elements that are the parent of another element, including text nodes. This is the inverse of :empty.

Source Code

<!DOCTYPE html>
  <script src="http://code.jquery.com/jquery-latest.js"></script>

	<h3>Text 1</h3>
<button>Click Here</button>

jQuery("button").click(function () {
	jQuery("h3:parent").css({border:"3px #1E8CBE solid"});


Following example finds all <h3> with children, including text and create a border.

Text 1


No comments yet.

Leave a Reply