Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Podmiana diva w javascript
binprogrammer
post
Post #1





Grupa: Zarejestrowani
Postów: 249
Pomógł: 8
Dołączył: 10.08.2011
Skąd: Bełchatów

Ostrzeżenie: (10%)
X----


Witam, chcę zrobić skrypt do temparmonkey i wie ktoś z Was jak podmienić diva?

np. mam <div id=trolo">tresc</div> i chcę zamienić na <div id="trolo" cos="trolo">tresc</div> możecie mi coś podpowiedzieć?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
binprogrammer
post
Post #2





Grupa: Zarejestrowani
Postów: 249
Pomógł: 8
Dołączył: 10.08.2011
Skąd: Bełchatów

Ostrzeżenie: (10%)
X----


Nie rozumiem, mam div na stronie <div class="klasa1"><h1>trolo</h1></div> i we wtyczce temparmonkey muszę podmienić na <div class="klasa1"><h1 class="klasa2">trolo</h1></div> wiecie może jak to najłatwiej zrobić?

  1. var my_div = null;
  2. var newDiv = null;
  3.  
  4. function addElement()
  5. {
  6. // tworzy nowy element div
  7. // i daje jego zawartość
  8. newDiv = document.createElement("div");
  9. newDiv.innerHTML = "<h1>trolo</h1>";
  10.  
  11. // add the newly created element and it's content into the DOM
  12. my_div = document.getElementByClass("klasa1");
  13. document.body.insertBefore(newDiv, my_div);
  14. }


W tą stronę idę, ale nie wiem czy dobrze
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 12.10.2025 - 21:30