我正在尝试选择与父元素相连的子元素。例如,在以下HTML中,我只想选择第二个和第四个段落的子元素(strong
),因为在这两种情况下,子元素和父元素是相邻的(即子元素和父元素之间没有文本或标记):
<p>This is line <strong>number one</strong></p>
<p><strong>This is line number two</strong></p>
<p>This <strong>is line number three</strong></p>
<p><strong>This is line</strong> number four</p>
如有可能,我该如何仅使用选择器来完成这个任务?!