Hello developers today we will learn how to edit table.
It’s possible without any need of third party plugin so let see it.
- index.html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="./styles.css"/> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous"> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js" integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN" crossorigin="anonymous"></script> <title>Document</title> </head> <body> <table class="table table-striped table-bordered w-50"> <thead> <th>Name</th> <th>Email</th> <th>Mobile Number</th> </thead> <tbody> <tr> <td><div contenteditable="true">Darshan</div></td> <td><div contenteditable="true">temp@gmail.com</div></td> <td><div contenteditable="true">9999999999</div></td> </tr> <tr> <td><div contenteditable="true">Hardik</div></td> <td><div contenteditable="true">temp@gmail.com</div></td> <td><div contenteditable="true">9999999999</div></td> </tr> <tr> <td><div contenteditable="true">Hit</div></td> <td><div contenteditable="true">temp@gmail.com</div></td> <td><div contenteditable="true">9999999999</div></td> </tr> </tbody> </table> </body> </html>
- styles.css
body{ display: flex; justify-content: center; align-items: center; height: 100vh; }
“contenteditable” can accept two values true & false
Here is Demo of editable table
Hope you found this blog helpful. Reach out in comment section if you have any doubt.