Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [JavaScript]Zmiana zawartości
sher
post 3.04.2015, 13:45:25
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
sher
post 3.04.2015, 14:25:17
Post #2





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).innerHTML;
  6. parseInt(ids);
  7. return ids.innerHTML = ids+1;
  8. }
  9. }

albo
  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).innerHTML;
  6. parseInt(ids);
  7. return ids = ids+1;
  8. }
  9. }

próbowałem tak i tak.

Edit: jestem upośledzony, zaraz to ogarnę, poczekajcie z odpisywaniem
Edit2: okej udało się,
  1. function down(id) {
  2. if (document.getElementById('up'+id).style.color == "black" && document.getElementById('down'+id).style.color == "black"){
  3. document.getElementById('down'+id).style.color = "red";
  4. document.getElementById('down'+id).style.BorderColor = "red";
  5. var ids = document.getElementById('rate'+id).innerHTML;
  6. var idx = document.getElementById('rate'+id);
  7. parseInt(ids);
  8. return idx.innerHTML = ids-1;
  9. }
  10. }

Jeszcze jedno pytanie, jak zrobić, żeby zamiast "01" wyświetlało się samo "1"? snitch.gif

Ten post edytował sher 3.04.2015, 14:31:41
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:30