English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Esempio di seguito:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>Documento senza titolo</title> </head> <body> <input type="text" value="Ho vinto, ho vinto un miliardo" id="mytext" /> <script language="javascript"> /* * 1. Ottenere il valore dell'attributo value con l'id mytext * 2. Ottenere il valore dell'attributo type con l'id mytext */ var txtElement = document.getElementById('mytext'); //Possiamo accedere agli attributi attraverso il modo oggetto.atрибuto. alert(txtElement.value); alert(txtElement.type); </script> </body> </html>
Questo è tutto il contenuto che l'editor vi ha portato su come accedere agli attributi dell'oggetto id in JavaScript (esempio di codice). Spero che tutti possano sostenere il tutorial di urla~