Find the parent element of each paragraph with a class "selected". : Selector « jQuery « JavaScript Tutorial

JavaScript Tutorial
1. Language Basics
2. Operators
3. Statement
4. Development
5. Number Data Type
6. String
7. Function
8. Global
9. Math
10. Form
11. Array
12. Date
13. Dialogs
14. Document
15. Event
16. Location
17. Navigator
18. Screen
19. Window
20. History
21. HTML Tags
22. Style
23. DOM Node
24. Drag Drop
25. Object Oriented
26. Regular Expressions
27. XML
28. GUI Components
29. Dojo toolkit
30. jQuery
31. Animation
32. MS JScript
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
JavaScript Tutorial » jQuery » Selector 
30. 2. 11. Find the parent element of each paragraph with a class "selected".
<html>
  <head>
    <script type="text/javascript" src="js/jquery-1.3.2.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
            $("p").parent(".selected").css("background""yellow");

        });
    </script>
  </head>
  <body>
    <body>
          <div><p>Hello</p></div>
          <div class="selected"><p>Hello Again</p></div>
          
    </body>
</html>
30. 2. Selector
30. 2. 1. Adds class to all divs that have a paragraph inside of them.
30. 2. 2. Ancestor descendant
30. 2. 3. Assign query result to variable
30. 2. 4. Contains another tag
30. 2. 5. Contains(text) matches elements which contain the given text.
30. 2. 6. Count hidden tags
30. 2. 7. Doest it contain
30. 2. 8. Find all elements is to set the 'context' to document.body
30. 2. 9. Find all elements within the 'context' (document.body)
30. 2. 10. Find tag from just added HTML
30. 2. 11. Find the parent element of each paragraph with a class "selected".
30. 2. 12. Finds every element (including head, body, etc).
30. 2. 13. HTML contains
30. 2. 14. Hides all paragraphs then the link on click.
30. 2. 15. Make all visible divs turn yellow on click.
30. 2. 16. Matches all elements
30. 2. 17. Matches all elements that are headers, like h1, h2, h3 and so on
30. 2. 18. Matches all elements that have no children (including text nodes)
30. 2. 19. Matches all elements with the given name.htm
30. 2. 20. Matches all input elements of type text.htm
30. 2. 21. Matches elements which contain the given text
30. 2. 22. Methods to obtain new wrapped set based on relationships
30. 2. 23. Removes all elements that match "div p.selected" from the total set of all paragraphs.
30. 2. 24. Select more than one
30. 2. 25. Show hidden div tags
30. 2. 26. empty() matches all elements that have no children (including text nodes).
30. 2. 27. header() matches all elements that are headers, like h1, h2, h3 and so on.
30. 2. 28. hidden() matches all elements that are hidden, or input elements of type "hidden".
30. 2. 29. jQuery custom filter selectors
30. 2. 30. not(selector) filters out all elements matching the given selector.
30. 2. 31. visible() matches all elements that are visible.
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.