【发布时间】:2017-01-14 06:29:22
【问题描述】:
按下“removeclass”按钮时出现问题。删除按钮应该删除一个按钮。它会这样做,但按钮也会被按下,这是不应该发生的,并且会改变视频播放器的时间。
如何在删除之前禁用该按钮?我试过使用 .prop("disabled", true) 没有运气。
//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);
}
【问题讨论】:
标签: javascript jquery google-chrome-extension youtube-api