0

is it possible to find the javascript that is setting an element attribute in chrome dev tools? or any other tool ?

Example:

Javascript set href in some external file

$('.buy_button').attr('href','asdf');

...then inside the main.html

<a href="asdf" class="buy_button">the link</a>

How do I find what is setting main.html in chrome dev tools or some other tool ?

2
  • 1
    Why not just look through the external JavaScript file for where it's changing the attribute? How big is the JavaScript file? Are you the author of these files? Commented Aug 5, 2014 at 18:05
  • 1
    arer u looking for this <a href="#" class="buy_button">the link</a> Commented Aug 5, 2014 at 18:14

3 Answers 3

4

Well, actually it IS possible:

  • locate the element you need to check (in 'Elements' tab)
  • open the context menu for that element (right-click on it)
  • choose 'Break on...', check 'Attributes modification' option

... and the script will pause (go into debugger mode) when attributes of that element are modified.

Sign up to request clarification or add additional context in comments.

1 Comment

How to find in case the attribute is modified, not on a user action, but on page load itself?
0

Actually this is not possible, you should go inside the javascript scripts and search it by your own. You should search for something like the id of the element, or the .attr() function and so on...

Comments

0

If you know what element type or class the JavaScript is hitting then you can open up that JS file in chrome or another IDE and just match the text to the class or element type that the JS is modifying.

The example on the first part of your example will hit anything with the class of buy_button so searching that would be a good start. You can open the JavaScript files inside of the Chrome inspection tool by finding them in the head tag and clicking on them. Once they are opened, you can then click anywhere and use CTRL+F to search for the class.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.