Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [JavaScript]Zmiana zawartości
sher
post
Post #1





Grupa: Zarejestrowani
Postów: 51
Pomógł: 0
Dołączył: 9.07.2014

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


  1. function up(id) {
  2. if (document.getElementById('up'+id).style.color == "black" && document.getElementById('down'+id).style.color == "black"){
  3. document.getElementById('up'+id).style.color = "green";
  4. document.getElementById('up'+id).style.BorderColor = "green";
  5. var ids = document.getElementById('rate'+id);
  6. parseInt(ids);
  7. return ids.innerHTML = ids+1;
  8. }
  9. }


Jak w elemencie jest cyfra 0, i powinno zmienić się na 1, to zamiast tego pojawia się "[object HTMLSpanElement]1". Jak pozbyć się tego tekstu przed jedynką?

Ten post edytował sher 3.04.2015, 13:54:33
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
markuz
post
Post #2





Grupa: Zarejestrowani
Postów: 1 240
Pomógł: 278
Dołączył: 11.03.2008

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


[JAVASCRIPT] pobierz, plaintext
  1. var up = function up(id) {
  2. var styleUp = document.getElementById('up' + id).style;
  3. var styleDown = document.getElementById('down' + id).style;
  4.  
  5. if(styleUp.color == 'black' && styleDown.color == 'black') {
  6. styleUp.color = 'green';
  7. styleUp.BorderColor = 'green';
  8. var id = parseInt(document.getElementById('rate' + id).innerHTML);
  9.  
  10. return (id + 1);
  11. }
  12.  
  13. return 0;
  14. };
[JAVASCRIPT] pobierz, plaintext


Jeżeli odnosisz się do jakiejś właściwości więcej niż 1 raz warto ją umieścić w zmiennej (wtedy kod jest wydajniejszy).
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: 22.08.2025 - 12:52