Javascript – Change JS code in Inspect Element Editor

domhtmljavascriptjquery

When I make some changes in html content using Chrome's Inspect Element editor the changes are immediately reflected. But when I make a change in Javascript code then the changes are not reflected.

Suppose on click of a button I say, alert "John is a Good boy" and When I change it to "John is a bad boy" using Inspect element(JS code) then the changes are not reflected on button click and the old text "John is a Good boy" gets displayed.

So when a page gets loaded, its not possible to edit the JS code and see the changes ? Why is it so ?

Best Answer

In my experience, the edits I've made to Javascript files have been reflected immediately. However, an easy fix you might try is as follows:

  • Insert a breakpoint on the line you want to edit
  • Reload the page (breakpoints will persist)
  • Edit that line when the breakpoint is hit
  • Click Continue on the debugger

If you need more information on breakpoints and the debugger, check out this link

If you want even more information on using the inspector tool, try searching through this tutorial