I am working in jupyter lab env using ipwidgets python library. I am making a dashboard environment using jupyter lab. The problem I am facing is that form some reason javascript is not working at all. I thought it would have been a problem with the environment I am using so I installed a fresh environment in a sandbox but it still does not work.
This is the example code that I am trying to run
from IPython.display import Javascript, display
import ipywidgets as widgets
# Define a function to display a JavaScript alert
def show_alert():
display(Javascript('alert("Hello from JavaScript!")'))
# Create a button widget
button = widgets.Button(description="Click me!")
# Set the button's action
button.on_click(lambda b: show_alert())
# Display the button
display(button)
For testing I run this code in google colab and It is working fine there.
When I run the code and clicke the ‘click me’ button I get the following output in the jupyter console