Your PHP runs on the server and prints some text.
The browser then interprets this text as HTML and JavaScript.
You cannot run PHP on the server, in a document that it has already sent to the browser, in response to the logic running in the browser.
You either need this completely in JavaScript, or, more safely, parse the server-side logic so that you keep track of whether jQuery is enabled or not.
Quentin
source share