admin管理员组

文章数量:1290946

I found in my university website there is a button to add course. Where can I find the function addNewCourseToStudent()details using inspect element of the google chrome.

<button onclick="addNewCourseToStudent()">Add</button>

I found in my university website there is a button to add course. Where can I find the function addNewCourseToStudent()details using inspect element of the google chrome.

<button onclick="addNewCourseToStudent()">Add</button>

Share Improve this question asked Mar 29, 2020 at 6:52 Mushfikunnabi NijhumMushfikunnabi Nijhum 711 gold badge1 silver badge9 bronze badges 1
  • look on script tags in the html / php file from that button or in js files included in that file.. – Walter Cejas Commented Mar 29, 2020 at 7:36
Add a ment  | 

2 Answers 2

Reset to default 5

An inline handler will almost certainly be referencing a global variable, so you can open the console and log the variable, which will give you the function location and its code:

const foo = 'some code';
function fn() {
  console.log('fn running');
}

// when you have the function name, console.dir it
// to find its location:
console.dir(fn);
// console.log it to find its code:
console.log(fn);

You can click on the link to the right of the [[FunctionLocation]] to get to the place in the Sources panel where the function is defined.

Right click inspect the tag or button,
Choose the Event Listeners Tab in the developer tools as shown below

Expand click it won't show as onclick it will show as click

本文标签: javascriptWhere can I find the function called by onclick using Inspect Element of ChromeStack Overflow