टेबलरो इंसर्टसेल () विधि :
उदाहरण
id="myRow" के साथ तालिका पंक्ति की शुरुआत में सामग्री के साथ नया सेल डालें:
var row = document.getElementById("myRow");
var x = row.insertCell(0);
x.innerHTML = "New cell";
परिभाषा और उपयोग
इंसर्टसेल () विधि एक सेल को वर्तमान पंक्ति में सम्मिलित करती है।
युक्ति: वर्तमान तालिका पंक्ति में किसी सेल को हटाने के लिए डिलीटसेल () विधि का उपयोग करें ।
ब्राउज़र समर्थन
Method | |||||
---|---|---|---|---|---|
insertCell() | Yes | Yes | Yes | Yes | Yes |
वाक्य - विन्यास
tablerowObject.insertCell(index)
पैरामीटर मान
Value | Description |
---|---|
index | Required in Firefox and Opera, optional in IE, Chrome and Safari. A number (starts at 0) that specifies the position of the new cell in the current row. The value of 0 results in that the new cell will be inserted at the first position. The value of -1 can also be used; which results in that the new cell will be inserted at the last position. If this parameter is omitted, insertCell() inserts the new cell at the last position in IE and at the first position in Chrome and Safari. This parameter is required in Firefox and Opera, but optional in Internet Explorer, Chrome and Safari. |
टेक्निकल डिटेल
प्रतिलाभ की मात्रा: | डाला गया सेल तत्व |
---|
और ज्यादा उदाहरण
उदाहरण
id="myRow" के साथ तालिका पंक्ति के अंत में सामग्री के साथ नया सेल डालें:
var row = document.getElementById("myRow");
var x = row.insertCell(-1);
x.innerHTML = "New cell";
उदाहरण
id="myRow" के साथ तालिका पंक्ति की अनुक्रमणिका स्थिति 2 पर सामग्री के साथ नया सेल डालें:
var row = document.getElementById("myRow");
var x = row.insertCell(2);
x.innerHTML = "New cell";
उदाहरण
पहली तालिका पंक्ति की शुरुआत में नया सेल डालें। तालिका पंक्तियों का संग्रह (.rows[0]) तालिका में सभी <tr> तत्वों का एक संग्रह देता है जिसमें आईडी "myTable" होती है। संख्या [0] पुनः प्राप्त करने के लिए तत्व निर्दिष्ट करती है, इस उदाहरण में, पहली तालिका पंक्ति। फिर हम इंडेक्स पोजीशन -1 पर नए सेल को इंसर्ट करने के लिए इन्सर्टसेल () का उपयोग करते हैं:
var firstRow = document.getElementById("myTable").rows[0];
var x = firstRow.insertCell(-1);
x.innerHTML = "New cell";
उदाहरण
id="myRow" के साथ तालिका पंक्ति से पहला सेल हटाएं:
var row = document.getElementById("myRow");
row.deleteCell(0);
उदाहरण
तालिका की शुरुआत में नई पंक्तियाँ डालें। insertRow() विधि तालिका में निर्दिष्ट अनुक्रमणिका पर एक नई पंक्ति सम्मिलित करती है, इस उदाहरण में, id="myTable" वाली तालिका की पहली स्थिति (शुरुआत)। फिर हम नई पंक्ति में कोशिकाओं को जोड़ने के लिए इन्सर्टसेल () विधि का उपयोग करते हैं।
var table = document.getElementById("myTable");
var row = table.insertRow(0);
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);
cell1.innerHTML = "NEW CELL1";
cell2.innerHTML = "NEW CELL2";
टेबलरो ऑब्जेक्ट