[CSS] & [JQUERY] [selettore] :first-child

:first-child (selettore CSS e jQuery) riguarda il primo Elemento HTML della selezione. E’ equivalente a :nth-child(1).

Sintassi

:first-child {
  /* codice */
}

Esempi

<table>
  <tr><td>1</td><td>2</td><td>3</td></tr>
  <tr><td>4</td><td>5</td><td>6</td></tr>
  <tr><td>7</td><td>8</td><td>9</td></tr>
  <tr><td>10</td><td>11</td><td>12</td></tr>
  <tr><td>13</td><td>14</td><td>15</td></tr>
</table>
<style>
tr:first-child {
  background-color: yellow;
}
</style>

1 2 3
4 5 6
7 8 9
10 11 12
13 14 15
<style>
ol > :first-child {
    background-color:yellow;
}
</style>
<ol>
  <li>a</li>
  <li>b</li>
  <li>c</li>
</ol>
<ol>
  <li>d</li>
  <li>e</li>
  <li>f</li>
</ol>

  1. a
  2. b
  3. c
  1. d
  2. e
  3. f

Contenuti correlati

  • CSS
  • HTML
  • JavaScript
  • jQuery
  • PHP
  • SQL
  • WORDPRESS

Fonti esterne

css, jquery, selettori css e jquery

Related Articles

0 Comment

Rispondi