Click here to Skip to main content
15,883,705 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, i have a div in which an inline style="height:200px" is applied. How can i find from which javascript/jquery function is this coming from?
Posted

In Chrome you can set breakpoints for when attributes are modified.

Right-click the element you want to watch and choose "inspect" from the menu. In the HTML view, right-click the element again and choose "Break on..." and then "Attributes modifications". That should drop you into the Javascript debugger when the style is changed.
 
Share this answer
 
Comments
Christian Graus 15-Dec-12 17:42pm    
Wow - I did not know that, thank you.
ophelia_123 15-Dec-12 17:43pm    
i tried that before.. the debugger does not open. i just see the breakpoint in the DOM Breakpoints section. Maybe because this style is applied on page load??
Graham Breach 15-Dec-12 19:15pm    
OK, then you can use the timeline view to record events and reload the page. Changes that make the page redraw are listed along with a link to where in the Javascript the update was caused.
You can use Chrome to debug and see what css styles are being applied. But, you can't tell if styles were applied directly, by what function. Try to apply them via CSS for a start. If you have a ton of functions that all do the same thing ( set the height to 200 ) then your code is a mess to start with. You could comment out different functions until you find the one that was applying it.
 
Share this answer
 
Comments
ophelia_123 15-Dec-12 16:50pm    
I Cant use the debug tool because i dont know from which file this style comes from. i just use the inspect element and see that a height is applied and i want to change it but i can't find how this is generated. i thought maybe there was a way to see which function adds this style... - it's not my code btw.
Christian Graus 15-Dec-12 17:01pm    
You can, actually. You can expand the Matched CSS rules, go through them, and see which one the height is coming from. The only way, if it's done with styles and not classes, is to comment out code and see what happens. Or just search the code for height: 200px.
ophelia_123 15-Dec-12 17:38pm    
im not sure i understand exactly what you mean. i have search for height:200px but i didn't find anything... the div has element.style {height:200px} maybe if you take a screenshot might help me (?)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900