Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [JS] Tworzenie elementów i odwołania do nich
speenatch
post 21.03.2010, 15:29:27
Post #1





Grupa: Zarejestrowani
Postów: 11
Pomógł: 0
Dołączył: 17.02.2010

Ostrzeżenie: (0%)
-----


Przepraszam, że może tytuł taki mało treściwy, ale nie miałem lepszego pomysłu.

Chciałbym po utworzeniu w kodzie nowego elementu:
  1. <div id="d"></div><br>
  2. <button type="button" onclick="fun()">A</button>
  3. <script type="text/javascript">
  4. var a = 0;
  5. function fun()
  6. {
  7. a = document.createElement('input');
  8. a.setAttribute('type', 'text');
  9. a.setAttribute('value', 'cośtam');
  10. a.setAttribute('id', 'jakiesid');
  11. document.getElementById('d').appendChild(a);
  12. }

usunąć go, ale nie na podstawie zmiennej a (document.getElementById('d').removeChild(a)), tylko jakoś tak, żeby z niej nie korzystać,

Próbowałem tak:
  1. document.getElementById('d').removeChild(getElementById('jakiesid'));

ale nie działa.

Proszę o jakiś sposób na zrobienie tego.
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 14.08.2025 - 03:46