push avec rien de particulier

This commit is contained in:
Clément Brossaud
2023-05-24 15:34:03 +02:00
parent 3586d0289b
commit cda794968e
2 changed files with 30 additions and 0 deletions

View File

@@ -12,6 +12,14 @@ img{
height: 20px;
}
#entry_text{
text-align: center;
}
.highlight {
background-color: yellow;
}
.publi{
display: flex;
flex-direction: column;

View File

@@ -0,0 +1,22 @@
function searchAndHighlight() {
const searchInput = document.getElementById('text_entry');
const searchTerm = searchInput.value.trim();
const content = document.getElementById('content');
const result = document.getElementById('result');
// Effacer le contenu précédent
result.innerHTML = '';
// Rechercher et mettre en évidence le terme de recherche
const regex = new RegExp(`\\b${searchTerm}\\b`, 'gi');
const matches = content.innerHTML.match(regex);
if (matches) {
matches.forEach(match => {
const matchElement = document.createElement('span');
matchElement.innerText = match;
matchElement.classList.add('highlight');
result.appendChild(matchElement);
});
}