I have an external *.js
file which contains the following code:
$(".hlavni_tema").click(function() {
alert("ok");
});
alert("loaded");
and an HTML page, as follows:
<div id="tema">
<span id="hlavni_tema_1" class="hlavni_tema">Základní fyzikální pojmy a jednotky</span>
<input type="checkbox" name="tema" id="tema_1a" value="'1a'">
<label for="tema_1a">Základní fyzikální pojmy, měření ve fyzice</label>
...
<span id="hlavni_tema_8" class="hlavni_tema">Astrofyzika</span>
<input type="checkbox" name="tema" id="tema_8d" value="'8d'">
<label for="tema_8d" class="posledni_label">Fyzikální obraz světa</label>
</div>
In the HEAD section, I include both the jQuery and external file sources, as follows:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="/_jscripts/tema.js"></script>
When I open the webpage, alert()
notifies "loaded"
, so that jQuery file is imported. But when I click on the span element whose class is "hlavni_tema"`, nothing happens. I've tried also with this code:
.on("click", function())
and
.on("click", "#tema", function())
-- all to no avail.
Thanks for any help.