Change the value of the content attribute of the third meta element with index 2 in head:
document.getElementsByTagName("META")[2].content = "new value";
<!DOCTYPE html> <html> <body> <head> <meta name="description" content="this is a description"> <meta name="keywords" content="test example tutorial"> <meta name="author" content="java2s.com"> </head>//from www .j a v a 2s. c o m <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { document.getElementsByTagName("META")[2].content = "new value"; document.getElementById("demo").innerHTML = "The content in meta name 'author' was changed'."; } </script> </body> </html>