الصفحة الرئيسية
تحميل الكود
تغيير الألوان
تغيير العرض
تغيير حجم العرض
تشغيل الكود
<!DOCTYPE html> <html> <body> <h1>JS Select Element with CSS selectors</h1> <p>document.querySelector() selects the first elements that match the specified selector.</p> <p class="demo">This content will changed by javascript.</p> <p class="demo">This content will not be selected.</p> <script> // element في متغير إسمه demo يساوي class و يملك <p> هنا قمنا بتخزين أول عنصر نوعه var element = document.querySelector('p.demo'); // element هنا قمنا بتغيير محتوى العنصر الذي يمثله المتغير element.innerHTML = 'My content is changed!'; </script> </body> </html>