0
votes

Comment obtenir une chaîne qui ont une couleur de fond et de couleur différente?

Comment obtenir une chaîne qui a de la couleur de fond et de la couleur différente? Sortie attendue forte> BCFE code>

Obtenir la sortie forte>: BCDEF code> P>

<table>
    <tr>
        <td style="background-color: #0d71bb;color: #0d71bb">A</td>
        <td style="background-color: #0ea432;color: #0f0f10">B</td>
        <td style="background-color: #e0b4b4;color: #e6a200">C</td>
    </tr>
    <tr>
        <td style="background-color: #FFFF00;color: #FF0">D</td>
        <td style="background-color: #a9d5de;color: #a3c293">E</td>
        <td style="background-color: #b4d95c;color: #b21e1e">F</td>
    </tr>

</table>


1 commentaires

Est-ce que l'ordre de la production (par exemple: est BCEF ) bien?


3 Réponses :


0
votes

Convertissez la couleur hexagonale en couleurs RGBA et faites-les correspondre


0 commentaires

1
votes

Vous obtenez les styles de vos balises td code> de manière assez inhabituelle. Je vous suggère d'utiliser jQuery's .CSS () code> méthode pour obtenir les couleurs Vous êtes après au lieu d'essayer de scinder la balise code> style code>: xxx pré>

également, notez que vous n'avez pas besoin d'utiliser .map () , plutôt que vous pouvez utiliser .Chafe () code> pour boucler sur chaque em> tr TD code> Elément. P>

Voir Travail Exemple ci-dessous: p>

p>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<table>
  <tr>
    <td style="background-color: #0d71bb;color: #0d71bb">A</td>
    <td style="background-color: #0ea432;color: #0f0f10">B</td>
    <td style="background-color: #e0b4b4;color: #e6a200">C</td>
  </tr>
  <tr>
    <td style="background-color: #FFFF00;color: #FF0">D</td>
    <td style="background-color: #a9d5de;color: #a3c293">E</td>
    <td style="background-color: #b4d95c;color: #b21e1e">F</td>
  </tr>
</table>


0 commentaires

0
votes

Vous pouvez comparer fond-couleur code> et couleur code> de la propriété de chaque élément et filtre en conséquence

p>

<table>
  <tr>
    <td style="background-color: #0d71bb;color: #0d71bb">A</td>
    <td style="background-color: #0ea432;color: #0f0f10">B</td>
    <td style="background-color: #e0b4b4;color: #e6a200">C</td>
  </tr>
  <tr>
    <td style="background-color: #FFFF00;color: #FF0">D</td>
    <td style="background-color: #a9d5de;color: #a3c293">E</td>
    <td style="background-color: #b4d95c;color: #b21e1e">F</td>
  </tr>
</table>
<button onclick='giveStrings()'>Clcik me</button>


0 commentaires