تصف هذه المقالة طريقة إضافة محتوى العقدة إلى نموذج ديناميكيًا. شاركه للرجوع إليه. التفاصيل كما يلي:
1. الكود
انسخ الرمز على النحو التالي: <! doctype html public "-// w3c // dtd xhtml 1.0 transitional // en" "http://www.w3
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv = "content-type" content = "text /html ؛ charset = utf-8" />
<title> إضافة عقدة </title>
<script type = "text/javaScript">
وظيفة newPicture () {
var picelement = document.createElement ("img") ؛
picelement.src = "Images/Success.jpg" ؛
picelement.width = 100 ؛
picElement.Height = 100 ؛
document.body.appendchild (picelement) ؛
}
وظيفة newNode () {
var olElement = document.getElementById ('الإجابات') ؛
var lielement = document.createElement ('li') ؛
var inputelement = document.createElement ('input') ؛
inputElement.type = "text" ؛
inputelement.name = "الإجابة" ؛
lielement.appendchild (inpectElement) ؛
ollement.appendchild (lielement) ؛
}
</script>
</head>
<body>
<viv>
<type type = "button" name = "button" value = "إضافة صورة" onClick = "javaScript: newPicture () ؛"/>
<type type = "button" name = "button" value = "إضافة خيار" onClick = "javaScript: newNode () ؛" /> <br />
<ol id = "الإجابات">
<li> <input type = "text" name = "applet" /> </li>
</ol>
</div>
</body>
</html>
2. عروض البرنامج:
آمل أن تكون هذه المقالة مفيدة لبرمجة JavaScript للجميع.