I have a php file as the main page. home.php. In this file I have used some codes like this. Body params.
<body user="<?php echo $_SESSION["LOGGED_USER"] ?>" status="<?php echo $_SESSION["STATUS"] ?>">
So when user logged in, this appears in the body tags. And i can take those values anytime. Now I need to change those values in runtime. I mean when user change the user email, i need to change that using javascript. How can I do that ?
You can use .attr( attributeName, value )
Set one or more attributes for the set of matched elements.
$('body').attr('user', newValue)
Using native .setAttribute(attributeName, value)
Adds a new attribute or changes the value of an existing attribute on the specified element. Returns undefined.
document.querySelector("body").setAttribute("user", "newValue")
Note: However to store arbitrary data, I would recommend you to use data-*
prefixed custom attributes.