Adding a button per each row with mouseover event + adding click event on button
Adding a button per each row with mouseover event + adding click event on button
pmorgado
Posts: 1Questions: 0Answers: 0
Hello,
It's my first time using datatable. I'm trying to add a button on each row with a mouseover on the table. And it works! The problem is when I want to bind the click event on the button, I can't catch the event. Can somebody help me, please?
[code]
var oTable = $('#table').dataTable();
$(oTable.fnGetNodes()).on("mouseover", function (event) {
$(this).closest('table').find('button#add_button').remove();
var $button = $("")
.text("Add");
$($button).on("click", function(event){alert("hello");});
$(this).append($button);
});
[/code]
It's my first time using datatable. I'm trying to add a button on each row with a mouseover on the table. And it works! The problem is when I want to bind the click event on the button, I can't catch the event. Can somebody help me, please?
[code]
var oTable = $('#table').dataTable();
$(oTable.fnGetNodes()).on("mouseover", function (event) {
$(this).closest('table').find('button#add_button').remove();
var $button = $("")
.text("Add");
$($button).on("click", function(event){alert("hello");});
$(this).append($button);
});
[/code]
This discussion has been closed.