কম্পিউটার টিউটোরিয়াল

HTML DOM Table rows কালেকশন: টেবিলের সব সারি (tr) পাওয়া

HTML DOM table rows কালেকশন একটি HTML ডকুমেন্টের টেবিলের সব <tr> এলিমেন্টের একটি কালেকশন রিটার্ন করে।

সিনট্যাক্স

সিনট্যাক্স নিচে দেওয়া হলো:

object.rows

rows কালেকশনের প্রোপার্টি

HTML ডকুমেন্টে কালেকশনে এলিমেন্ট।

প্রোপার্টি ব্যাখ্যা
length HTML ডকুমেন্টে কালেকশনে <tr> এলিমেন্টের সংখ্যা রিটার্ন করে।

rows কালেকশনের মেথডসমূহ

কালেকশন এলিমেন্ট থেকে এলিমেন্ট। কালেকশন এলিমেন্ট থেকে এলিমেন্ট

মেথড ব্যাখ্যা
[index] কালেকশন থেকে নির্দিষ্ট ইন্ডেক্সের <tr> এলিমেন্ট রিটার্ন করে।
item(index) <tr> কালেকশন থেকে নির্দিষ্ট ইন্ডেক্সের <tr> এলিমেন্ট রিটার্ন করে।
namedItem(id) কালেকশন থেকে নির্দিষ্ট id-যুক্ত <tr> এলিমেন্ট রিটার্ন করে।

উদাহরণ

HTML DOM table rows কালেকশনের একটি উদাহরণ:

<!DOCTYPE html> <html> <style>    body {       color: #000;       background: lightblue;       height: 100vh;       text-align: center;    }    table {       margin: 2rem auto;    }    .show {       font-size: 1.2rem;    }    .btn {       background: #db133a;       border: none;       height: 2rem;       border-radius: 2px;       width: 40%;       display: block;       color: #fff;       outline: none;       cursor: pointer;       margin: 1rem auto;    }    .show {       font-size: 1.2rem;    } </style> <body> <h1>DOM Table rows Collection Demo</h1> <table border="2"> <thead> <tr> <th>Name</th> <th>Roll No.</th> </tr> <thead> <tbody> <tr> <td>John</td> <td>071717</td> </tr> <tr> <td>Jane</td> <td>031717</td> </tr> </tbody> </table> <button onclick="get()" class="btn">Get Number of Rows</button> <div class="show"></div> <script>    function get() {       var table = document.querySelector('table');       document.querySelector('.show').innerHTML = 'Number of rows : ' + table.rows.length;    } </script> </body> </html>

আউটপুট

HTML DOM Table rows কালেকশন: টেবিলের সব সারি (tr) পাওয়া

"Get Number of Rows" বাটনে ক্লিক করুন কালেকশন থেকে <tr> এলিমেন্টের সংখ্যা পাওয়ার জন্য।

HTML DOM Table rows কালেকশন: টেবিলের সব সারি (tr) পাওয়া

  1. HTML DOM TableHeader অবজেক্ট: টেবিল হেডার সেল (th) নিয়ন্ত্রণ

  2. HTML DOM Table tHead প্রোপার্টি: টেবিল হেডার (thead) অ্যাক্সেস

  3. HTML DOM Table tFoot প্রোপার্টি: টেবিল ফুটার (tfoot) অ্যাক্সেস

  4. HTML DOM Textarea rows প্রপার্টি