user3102785 user3102785 - 7 months ago 11
HTML Question

Button click not firing anymore

I'm making a website, and within it there are a few buttons. These stopped working in the last day or two for some reason that I cannot figure out.

Here is the Click function.

//Click "Belgium"
$('#actions').on('click', '#btnBelgium', function ()
{
console.log("belgium pressed");
clearTableRows();
irelandMatches.length = 0;
nation = "belgium";
loadDoc();
document.getElementById("btnSort").value = "Sort: Descending";
matchOrderReversed = false;
});


This is the HTML:

<div id="actions">
<input type="submit" class="navButton" value="Sort: Descending" id="btnSort">

<input type="submit" class="navButton" value="" id="btnBelgium">
<input type="submit" class="navButton" value="" id="btnIreland">
<input type="submit" class="navButton" value="" id="btnItaly">
<input type="submit" class="navButton" value="" id="btnSweden">
</div>


The entire section page of Javascript is contained within:

$(document).ready(function ()

Answer

The piece of code you provided works. Button click if firing. Check if you have any errors in js console in dev tools. There should be some other problem.

    //Click "Belgium"
    $('#actions').on('click', '#btnBelgium', function ()
    {
        console.log("belgium pressed");
        alert('clicked');
        clearTableRows();
        irelandMatches.length = 0;
        nation = "belgium";
        loadDoc();
        document.getElementById("btnSort").value = "Sort: Descending";
        matchOrderReversed = false;
    });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="actions">
        <input type="submit" class="navButton" value="Sort: Descending" id="btnSort">

        <input type="submit" class="navButton" value="" id="btnBelgium">
        <input type="submit" class="navButton" value="" id="btnIreland">
        <input type="submit" class="navButton" value="" id="btnItaly">
        <input type="submit" class="navButton" value="" id="btnSweden">
    </div>

Comments