mirror of
https://github.com/groupe1cir1n/groupe1CIR1Njs.git
synced 2026-03-18 21:40:30 +01:00
push avec rien de particulier
This commit is contained in:
@@ -12,6 +12,14 @@ img{
|
||||
height: 20px;
|
||||
}
|
||||
|
||||
#entry_text{
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.highlight {
|
||||
background-color: yellow;
|
||||
}
|
||||
|
||||
.publi{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
22
src/js/publication/publication.js
Normal file
22
src/js/publication/publication.js
Normal 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);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user