简体   繁体   中英

A link only after the second click

It is necessary not to follow the link on the first click and resolve only after the second . I wrote code :

$(".categoriesPage .categoryBox .textBox").attr("data-count", "0");
$(".categoriesPage .categoryBox .textBox").on("click", function(){
    $(this).each(function() {
        var clickCount = $(this).attr("data-count");
        clickCount ++;
        if (clickCount == 1) {
            $(this).attr("dataCount", clickCount);
            return false;
        } else {
            return true;
        }
    });
});

It does not work , the error may be what ?

$(".categoriesPage .categoryBox .textBox").attr("data-count", "0");
    $(".categoriesPage .categoryBox .textBox").on("click", function() {
        var clickCount = $(this).attr("data-count");
        clickCount++;
        if (clickCount == 1) {
            $(".categoriesPage .categoryBox .textBox[data-count='1']").attr("data-count", "0");
            $(this).attr("data-count", clickCount);
            return false;
        } else {
            return true;
        }
    });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM