简体   繁体   中英

event click not working same class on multiple anchor tag in td elements

i am using dataTables plugin for showing data as a grid but thier is attribute formatter in which i am am appending anchor a in td as well as applying class on this but when i am binding event it's not firing instead it's refreshing page i don'nt know why can any one about this let me correct what's going wrong.

Its showing perfectly image in grid as well class showing but behaviour is wiered regarding click event fire its refreshing page when i am clicking.

main.js:-

$(".deleteRequest a").click(function (e) {
    e.preventDefault();
    console.log("click");
    var r=confirm("Are u sure you want to delete This Request info");
            if (r==true)
            {

            }           
});

 formatter: function (timeOutes) {
                    $.each(timeOutes, function (index, timeOut) {
                        timeOut.id = '<a attrId = " ' + timeOut.id + '" href="" class="deleteRequest"><i class="icon-trash"></i></a>';
                    });
                }

您需要阻止链接默认操作(极有可能回发)-

e.preventDefault(); //add me to your click handler!

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