Birinchi muammo, document.getElementByID (... document.getElementByID (... document document
) uchun #counter
elementini hali qo'shmaganligingizdir. );
usulida ( hali ).
Agar elementni boshqarish imkoniga ega bo'lish uchun siz uni hujjatga qo'shishingiz kerak, buning uchun siz foydalanmoqchi bo'lardingiz:
// appends the new "div" element to the body (I.E: inserts the new element at the end of the body)
$("body").append("<div id='element-id'>Hello World!</div>");
Siz ushbu usullardan foydalanishingiz mumkin:
// replaces the "innerHTML" of the "body" element with the new "div" element
$("body").html("<div id='element-id'>Hello World!</div>");
// prepends the new div to the body (I.E: inserts the element as the first child not the last child)
$("body").prepend("<div id='element-id'>Hello World!</div>");
Endi ikkinchi muammo shundaki siz olishni CSS xususiyatining qiymatini va NOT sozlamasini qabul qilishingiz kerak.
CSS funktsiyasining joriy qiymatini olish uchun quyidagicha foydalanasiz:
$("#element-id").css("property-name")
JQuery-da CSS xususiyatining qiymatini o'zgartirish uchun parametrini ishlatasiz:
// listen for an event to occur
$(document).on("event-name", function() {
//change a single property of the element
$("#element-id").css("property", "new-value");
});
Shuningdek, bu kabi JavaScript ob'ektidan foydalanib, elementning bir nechta xususiyatini birdan o'zgartirishi mumkin:
// listen for an event to occur
$(document).on("event-name", function() {
//change multiple properties of the element using a JavaScript object
$("#element-id").css({
"property-name-one": "new-value",
"property-name-two": "new-value"
});
});
Yuqorida keltirilgan jQuery usullari haqida ko'proq ma'lumot olish uchun quyidagi havolalarni ko'rib chiqing:
Umid qilamanki bu yordam, omad va barcha yaxshi narsalar.