Search code examples
javascriptjquerygoogle-chromechrome-app-developer-tool

Chrome Developer Tools - Find matching Name or Id attribute in Javascript?


When I highlight the input on the Chrome browser and then click on "Inspect Element" from right-click menu then Chrome Developer Tools will popup.

Assume in the Chrome Developer Tools, this will appear:

<input type="radio" name="lineType_phone" id="lineType_new" value="new">

When I click on the input, the hidden div will appear. I would like to see how it was coded in JavaScript.

Is there a way to search for name="lineType_phone" or id="lineType_new" in any of JavaScript files or debug click event for this attributes/input?


Solution

  • Looking for files might not solve your problem. As sometimes files are minified or events have use lots of variables which means that searching for name="lineType_phone" might not be helpful.

    What about searching for events bound to the element?

    The code below will show events bound to the element itself

    $._data( $("#myElement")[0], "events" ); //don't forget to get the first elem of array
    

    However, some events are added through delegation. That means that the event might be bound to a parent DOM element. If that's the case, try looking for events on the parent like this:

    $._data( $("#myElement").parent()[0], "events" );