+ 6
Determine if click event exist on td and change cursor to pointer
We have a bunch of html pages with a click event attached to table / td(s) and it is not user friendly at all. Most of the pages are using Dynatable plugin to load and display data in those tables. Now, is there a simple way to determine which tables/td(s) have a click event attached to them and change the cursor style to a pointer on that td(s)?
4 Réponses
+ 6
I think I have found solution: https://code.sololearn.com/WFSE8Q7bCV6D/?ref=app
+ 6
Thanks Calviղ but that is not helping, if you are interested please look at my solution I am quite happy with it, it covers all to(s) on a page even if they are dynamically loaded, thanks again
+ 5
I think my solution also can cover dynamically loading, just run and test it, some more i think for simple solution, always go for pure js, rather than loading a whole jquery for a simple task.
Btw, your task is simple to solve by using a css only, without using any js
Just add
td[onclick] {
cursor: pointer;
}
Just hope it help. Cheers
+ 3
Try this
var table = document.getElementById("table")
table.addEventListener("click", onClick, false)
function onClick(event) {
if(event.target.tagName === "TD")
event.target.style.cursor = "pointer"
}
https://code.sololearn.com/WGD3b8GmSdE9/?ref=app