deleteData()
XML DOM deleteData() metodi
❮ Comment obyekti
Misol
Quyidagi kod fragmenti "books_comment.xml" faylini xmlDoc’ga yuklaydi va birinchi izoh tugunidan bir nechta belgini o‘chiradi:
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
myFunction(this);
}
};
xhttp.open("GET", "books_comment.xml", true);
xhttp.send();
function myFunction(xml) {
var x, i, xmlDoc, txt;
xmlDoc = xml.responseXML;
txt = "";
x = xmlDoc.getElementsByTagName("book")[0].childNodes;
for (i = 0; i < x.length; i++) {
// Process only comment nodes
if (x[i].nodeType == 8) {
x[i].deleteData(0,33);
txt += x[i].data + "<br>";
}
}
document.getElementById("demo").innerHTML = txt;
}
Natija:
(Hardcover)
O‘zingiz sinab ko‘ring »
Yuqoridagi misolda faqat izoh tugunlarini qayta ishlayotganimizga ishonch hosil qilish uchun sikl va if-tekshiruvdan foydalanamiz. Izoh tugunining tugun turi 8 ga teng.
Ta’rif va qo‘llanilishi
deleteData() metodi izoh tugunidan ma’lumotni o‘chiradi.
Sintaksis
commentNode.deleteData(start,length)| Parametr | Tavsif |
|---|---|
| start | Majburiy. Belgilarni o‘chirish qayerdan boshlanishini belgilaydi. start qiymati noldan boshlanadi |
| length | Majburiy. Nechta belgi o‘chirilishini belgilaydi |
❮ Comment obyekti
W3Schools Pathfinder
Yutuqlaringizni kuzating – bu bepul!
