Home
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> <script> $(document).ready(function () { $('p:only-child').append(" - This element is the only child element of the parent element"); }); </script> </head> <body> <h1>CSS Selector: element:only-child </h1> <div> <p>Inside div - Paragraph 1</p> </div> <span> <p>Inside span tag - Paragraph 1</p> <p>Inside span tag - Paragraph 2</p> </span> </body> </html>
Result: