vikas devde
vikas devde

Reputation: 11751

How to find JS code is working in browser?

I am using bootstrap modal, I dont know where I have put the js code that triggers the modal after clicking the button.

jQuery('#signin').modal('show');

I checked each file...even checked each JS file in source in browser.

How can I find which code is triggering the event in browser when I am clicking the button to open a modal?

Upvotes: 0

Views: 251

Answers (2)

Kevin Bowersox
Kevin Bowersox

Reputation: 94479

Use a developer tool for a browser which will allow you to perform Javascript debugging. Your best bet is most likely Firebug. If you set a debug point at a line within a JS file, firebug will allow you to inspect the stack to see which line has called the function.

Instructions

  1. In Firebug, click the script tab.
  2. Select your .js file using the drop down.
  3. When the JS file displays find the target line and click to the left of it, setting a debug point.
  4. Load your page, the script should stop at your debug point.
  5. Click the Stack tab on the right and inspect.

enter image description here

Searching for Script in Firebug

If you click the script tab you can enter a known piece of the script in the upper right hand corner of firebug, this should take you to its location in the code.

Upvotes: 4

R. Oosterholt
R. Oosterholt

Reputation: 8080

I agree with Kevin, another option is to print the stack trace using something like: http://www.codeovertones.com/2011/08/how-to-print-stack-trace-anywhere-in.html

Upvotes: 1

Related Questions