I have a problem when my 'removeclass' button is pressed. The remove button is supposed to remove a button. It does this, but the button is also pressed, which is not supposed to happen and changes the video player time.
How can I disable the button before removal? I have tried using .prop("disabled", true) with no luck.
//remove button function
$("body").on("click",".removeclass", function(e){
var site = document.URL;
if (site.includes('#')) {
site = site.substring(0, site.length - 1);
}
$(this).parent('div').children().prop("disabled", true);
timearray = JSON.parse(localStorage.getItem(site));
timepoint = parseInt($(this).parent('div').attr("id"), 10);
var index = timearray.indexOf(timepoint);
if (index > -1) {
timearray.splice(index, 1);
localStorage.setItem(site, JSON.stringify(timearray));
console.log(JSON.parse(localStorage.getItem(site)));
$(this).parent('div').remove();
}
});
//Creates button
function createButton(timepoint) {
var dispTime = convertTime(parseInt(timepoint, 10));
var r = $('<div id='+ timepoint + ' style="float: left"> <input type="button" ID='+ timepoint + ' value=' + dispTime + '> <a href="#" class="removeclass">Remove</a> </div>');
timepoint = parseInt(timepoint, 10);
r.click(function() {
$('video').get(0).currentTime = timepoint;
});
$("#watch-headline-title").append(r);
}
