<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<script src="script.js"></script>
<script>
function bgChange(bg) {
document.body.style.background = bg;
}
</script>
</head>
<body>
<h3>Monumentos existentes en la Ciudad de Cáceres</h3>
<p>Localiza los monumentos, por nombre, a través del buscador</p>
<input type="text" id="myInput" onkeyup="myFunction()" placeholder="Buscar por nombre">
<table id="myTable">
<tr class="header">
<th style="width:30%;">Tipo</th>
<th style="width:40%;">Monumento</th>
</tr>
<tr>
<td>Concatedral</td>
<td>Concatedral de Santa Maria</td>
</tr>
<tr>
<td>Convento</td>
<td>Convento de San Pablo</td>
</tr>
<tr>
<td>Convento</td>
<td>Convento de Santa Clara</td>
</tr>
<tr>
<td>Ermita</td>
<td>Ermita de la Paz</td>
</tr>
<tr>
<td>Ermita</td>
<td>Ermita de la Soledad</td>
</tr>
<tr>
<td>Iglesia</td>
<td>Iglesia San Francisco Javier</td>
</tr>
<tr>
<td>Iglesia</td>
<td>Iglesia San Mateo</td>
</tr>
<tr>
<td>Iglesia</td>
<td>Iglesia Santiago</td>
</tr>
<tr>
<td>Iglesia</td>
<td>Iglesia Santo Domingo</td>
</tr>
<tr>
<td>Arco</td>
<td>Arco de la Estrella</td>
</tr>
<tr>
<td>Arco</td>
<td>Arco de Santa Ana</td>
</tr>
<tr>
<td>Casa</td>
<td>Casa de los Paredes Saavedra</td>
</tr>
<tr>
<td>Palacio</td>
<td>Palacio del Comendador de Alcuescar</td>
</tr>
<tr>
<td>Palacio</td>
<td>Palacio Enfermeria de San Antonio</td>
</tr>
<tr>
<td>Palacio</td>
<td>Palacio Episcopal</td>
</tr>
<tr>
<td>Palacio</td>
...
CSS
h3 {
color: #808080;
font-family: "Big Caslon", "Book Antiqua", "Palatino Linotype", Georgia, serif;
font-size: 200%;
}
#myInput {
background-image: url('https://www.w3schools.com/css/searchicon.png'); /* Añadimos un icono de búsqueda al input*/
background-position: 10px 12px; /* Ubicamos la posición del icono */
background-repeat: no-repeat; /* Indicamos que no se repita la imageb */
width: 100%; /* Le damos ancho completo */
font-size: 16px; /* Le damos tamaño */
padding: 12px 20px 12px 40px; /* Le damos el padding */
border: 1px solid #ddd; /* Añadimos un borde gris */
margin-bottom: 12px; /* Añadimos espacio en el borde superior */
}
#myTable {
border-collapse: collapse; /* Fusionamos los bordes de la tabla */
width: 100%;
border: 1px solid #ddd;
font-size: 18px;
}
#myTable th, #myTable td {
text-align: left;
padding: 12px;
}
#myTable tr {
/* Añadimos un borde superior a la tabla */
border-bottom: 1px solid #ddd;
}
#myTable tr.header, #myTable tr:hover {
/* Añadimos un fondo gris claro al encabezado de tabla */
background-color: #f1f1f1;
}
JavaScript
function myFunction() {
// Declaramos las variables
var input, filter, table, tr, td, i;
// Las inicializamos
input = document.getElementById("myInput");
filter = input.value.toUpperCase();
table = document.getElementById("myTable");
tr = table.getElementsByTagName("tr");
/* Hacemos un bucle a través de todas las filas de la tabla y ocultamos
las que no coinciden con la consulta de búsqueda */
for (i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td")[0, 1];
if (td) {
if (td.innerHTML.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
}
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Get Fiddle Pages with PRO
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.