🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.www
Article #408750

Re: getElementById zwraca null

#408750
From: Marek S
Date: Mon, 19 Nov 2018 21:57
19 lines
1524 bytes
W dniu 2018-11-19 o 08:54, Jivanmukta pisze:

>      document.getElementById("main_title").innerHTML = s;

No więc widzę, że trafiłem w sedno :-) Standardowy błąd.

> Czy gdybym zamiast innerHTML umieścił wszystkie literki w span'ach i 
> ustawiał tylko atrybut class odpowiedniej literki to byłoby lepiej?

Zdecydowanie lepiej. A jeśli z jakiegoś powodu musisz zmieniać HTML, to 
rób to tym:

https://developer.mozilla.org/en-US/docs/Web/API/Element/insertAdjacentHTML

Po to powstała ta funkcja by nie używać innerHTML.

-- 
Pozdrawiam,
Marek
Technical Details
Message-ID: <psvbkh$rc9$1@node1.news.atman.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!.POSTED!not-for-mail
References: <psa4kg$1d6er$1@portraits.wsisiz.edu.pl> <pss93t$rda$1@node1.news.atman.pl> <pstq77$1p1on$1@portraits.wsisiz.edu.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!.POSTED!not-for-mail
From: Marek S <precz@spamowi.com>
Newsgroups: pl.comp.www
Subject: Re: getElementById zwraca null
Date: Mon, 19 Nov 2018 22:57:32 +0100
Organization: ATMAN - ATM S.A.
Lines: 19
Message-ID: <psvbkh$rc9$1@node1.news.atman.pl>
References: <psa4kg$1d6er$1@portraits.wsisiz.edu.pl> <pss93t$rda$1@node1.news.atman.pl> <pstq77$1p1on$1@portraits.wsisiz.edu.pl>
NNTP-Posting-Host: 89-70-94-204.dynamic.chello.pl
Mime-Version: 1.0
X-Trace: node1.news.atman.pl 1542664657 28041 89.70.94.204 (19 Nov 2018 21:57:37 GMT)
X-Complaints-To: usenet@atman.pl
NNTP-Posting-Date: Mon, 19 Nov 2018 21:57:37 +0000 (UTC)
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0
In-Reply-To: <pstq77$1p1on$1@portraits.wsisiz.edu.pl>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit