<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap demo</title>
<style>
.highlight {
background-color: yellow;
}
</style>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
</head>
<body>
<h1>Hello, world!</h1>
<nav class="navbar navbar-expand-lg bg-body-tertiary">
<div class="container-fluid">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Dropdown
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="#">Something else here</a></li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
</li>
</ul>
<form class="d-flex" role="search">
<input class="form-control me-2" type="text" placeholder="Search" aria-label="Search" id="searchBar">
<button class="btn btn-outline-success" type="submit" onclick='searchContent()'>Search</button>
</form>
<script>
function searchContent() {
var searchText = document.getElementById('searchBar').value.toLowerCase();
clearHighlights();
if (searchText === '') return;
highlightText(document.body, searchText);
}
function clearHighlights() {
var highlightedElements = document.querySelectorAll('.highlight');
highlightedElements.forEach(function(el) {
var parent = el.parentNode;
parent.replaceChild(document.createTextNode(el.textContent), el);
parent.normalize();
});
}
function highlightText(node, searchText) {
if (node.nodeType === 3) {
var val = node.nodeValue.toLowerCase();
var idx = val.indexOf(searchText);
if (idx !== -1) {
var span = document.createElement('span');
span.className = 'highlight';
var text = node.splitText(idx);
text.splitText(searchText.length);
var highlight = text.cloneNode(true);
span.appendChild(highlight);
text.parentNode.replaceChild(span, text);
return 1;
}
} else if (node.nodeType === 1 && node.nodeName !== 'SCRIPT' && node.nodeName !== 'STYLE') {
for (var i = 0; i < node.childNodes.length; i++) {
i += highlightText(node.childNodes[i], searchText);
}
}
return 0;
}
document.getElementById('searchBar').addEventListener('input', function() {
if (this.value === '') {
clearHighlights();
}
});
</script>
</div>
</div>
</nav>
<p>hlo all i am mohit shakya i like to eat mango</p>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
</body>
</html>