Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] click event callback #20

Open
erwinyusrizal opened this issue Jul 9, 2021 · 3 comments
Open

[Feature Request] click event callback #20

erwinyusrizal opened this issue Jul 9, 2021 · 3 comments

Comments

@erwinyusrizal
Copy link

Hi @luoye-fe can I request a click event callback ? it will return the callback with inspector.target

thank you

@zzm88
Copy link

zzm88 commented Aug 26, 2021

I also need this. I tried to bind a click event on the .dom-inspector class, but it doesn't have any response.

@jasdeep-compro
Copy link

Any Idea how can we get the selected DOM element ?

@surapich
Copy link

surapich commented May 9, 2023

This is how I did it

  1. Add an event listener for click event
    document.addEventListener("click", onClicked, false);
  2. In the click event get the element that was click and use the library's api to get more element data

In my case I also checked whether the inspector is toggled on or not

function onClicked(e) {
  if (!inspectorToggled) {
    return;
  }

  // Get element
  e = e || window.event;
  var target = e.target || e.srcElement;

  e.stopPropagation();
  e.preventDefault();

  const xpath = inspector.getXPath();
  const selector = inspector.getSelector();
  const eleInfo = inspector.getElementInfo();
  const mousePosition = {
    x: e.clientX,
    y: e.clientY,
  };
  const location = window.location.toString();

  // Do sometjing with the element
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants