Tuesday, 15 January 2013

javascript - Without the file or function name, how do I find a function that is making changes on an element? -



javascript - Without the file or function name, how do I find a function that is making changes on an element? -

i have big project. dozens of js files. element on page has click event attached it. want edit click event, first need locate its' file & line. how can that, without knowing function name or file name before hand? there way watch element in firebug , record function beingness executed?

backstory:

the element has .open class beingness added when clicked, , removed when user clicks on else. want have .open class added on mouseover, , removed on mouseout. want utilize same function beingness called in click event, first need find it.

thanks.

if using jquery add together event can find handler of event using code in firebug's console:

jquery._data($(".somehtmlelement")[0], "events")

you find location of handler under "handler" property, click on function jump corresponding line in code.

if not using jquery native addeventlistener can utilize this:

geteventlisteners($(".rs-btn")[1])

the function under property "listener"

javascript jquery debugging firebug

No comments:

Post a Comment