I have created some metro-bootstrap tiles to represent different checkbox options for my web application. Please find below the HTML/JS portion of the code:
<link rel="stylesheet" href="{{ url_for('static', filename='css/metro-bootstrap.css') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='css/metro-bootstrap.min.css') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='css/metro-bootstrap.css.map') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='css/font-awesome.min.css') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='css/font-awesome.css') }}">
<div class="well well-sm">
<h2><font color="green">Features:</font></h2>
<div class="grid">
<div class="row col-md-12">
<div class="tile tile-custom tile-turquoise col-xs-6 col-md-2">
<div class="checkbox col-md-5">
<p><h4>{{ form.profiles }}</h4></p>
<a href="#" class="fa-links">
<h1> Opt 1 </h1>
<i class="fa fa-4x fa-signal"> </i>
<h4> test profiles</h4>
</a>
</div>
<div class="tile tile-custom tile-purple col-xs-6 col-md-2">
<a href="#">
<h1> Opt 2</h1>
</a>
</div>
<div class="tile tile-custom tile-red col-xs-6 col-md-2">
<a href="#">
<h1> Opt 3</h1>
</a>
</div>
</div>
</div>
</div>
$(".tile").on('click', function() {
$(".tile").removeClass("activeTile");
$(this).toggleClass("activeTile");
});
.tile:not(.activeTile):hover{background-color: #0047AB;}
Is it possible to make these tiles select able by adding a check box on top-right of each tile and when you click anywhere on the tile then the checkbox be "checked"? Any help would be appreciated.
The current jquery code will cause a change in a tile background color by hovering the mouse over each tile. I tried to create the JS Fiddle of it: however, the check box does not appear since it does not understand my form.profiles variable. https://jsfiddle.net/smq95e9t/