I'm trying to link this button with #analyzebutton
id
<div class="pd-upload-foto">
<div class="vertical-center text-center">
<button id="startbutton" class='btn btn-ambilfoto btn-sm btn-1 font-3' style='padding-top:.2rem; padding-bottom:.2rem;' type='button'>ambil foto</button>
<button id="analyzebutton" class='btn btn-sm btn-1 font-3' style='padding-top:.2rem; padding-bottom:.2rem; display: none;' type='button'>mulai analisis</button>
</div>
</div>
<div class="pd-analisa" style="display: none;">
<div class="vertical-center text-center">
<button id="analyzingbutton" class='btn btn-sm btn-1 font-3' style='padding-top:.2rem; padding-bottom:.2rem;' type='button'>mulai analisa</button>
<img id="tesfotomasuk" src="" alt="tes aja">
</div>
</div>
with this JQuery script
$(".btn-ambilfoto").click(function() {
$(".btn-ambilfoto").html("berhasil").attr("disabled", "true");
$(".btn-ambilfoto").removeClass("btn-1").addClass("btn-4");
$("#analyzebutton").show();
});
$("#analyzebutton").click(function() {
$(".pd-upload-foto").hide();
$(".pd-analisa").show();
$("#analyzingbutton").html("Analyzing...");
});
When I press the #analyzebutton
button, it should fire the on click function and executes the function, but it doesn't. It's
I also have linked the JQuery script and the JS script at bottom of the html file.
Somehow, #analyzebutton
is the only that doesn't work. The .btn-ambilfoto
button (located just above the #analyzebutton
) works without problem.
I've tried to change the code to $(selector).on("click", function(){})
but it doesn't work either.
How should I fix this? I've spent more than 6 hours to just to fix this.
display: none
.$("#id").click
will only apply to elements that exist at the time the code runs (assuming the code runs), so trying to establish that the element exists at that time, which it appears it doesn't, or your code is simply not running.$(document).on("click", "#analyzebutton", function() ..
would the code to use if it's created later ("dynamically created"). But if you're code isn't even running...