I have the following snippet of code and I want only show the headers on mobile unless the header is clicked. Tried a few things but nothing works.
Bootstrap has classes you can use to show or hide content at certain breakpoints: hidden-xs
, hidden-sm
, etc. You'd probably want hidden-xs
.
You can then hav ea click handler on your h3
elements that toggles that class on the h5
. This will be a no-op on larger screens, but on smaller ones it will show/hide the element.
In this example I use jQuery for the JavaScript part (using event delegation), but that's a detail; the point is the concepts and the responsive classes provided by Bootstrap:
$(".container-fluid").on("click", "h3", function() {
$(this).nextAll("h5").first().toggleClass("hidden-xs");
});
Executive hire
Mercedes
Bently
Rolls Royce
Jaguar
Range Rover
BMW
Audi
Coach Hire
24 Seater coach
29 Seater coach
33 Seater coach
49 Seater coach
51 Seater coach
53 Seater coach
61 Seater coach
87 Seater coach
Limo Hire
White Limo
Black Limo
Pink Limo
Hummer Limo
Fire Engine Limo
Jeep & Novelty Limo
Minibus Hire
10 Seater minibus
11 Seater minibus
12 Seater minibus
14 Seater minibus
14 Seater minibus
15 Seater minibus
16 Seater minibus
Services
Private & Corporate Travel
Local & National Journeys
Airport Transfers
Sporting Events
Weddings
Theatre Trips
Stag & Hen Parties
AREAS COVERED