Article View: pl.comp.lang.javascript
Article #39882Re: zmiana elementu klasy css
From: Bogdan Blaszczak
Date: Mon, 15 May 2006 19:45
Date: Mon, 15 May 2006 19:45
37 lines
1791 bytes
1791 bytes
yew napisaล(a):
>> .klasa
>> { margin: 5px; }
>
>
> element.className
Tym mozesz przyporzadkowac inna klase dla danego elementu.
A jemu raczej chodzi o zmiane wartosci reguly (obiekt cssRule) w arkuszu
stylu (obiekt stylesheet)
To bedzie mniej wiecej cos takiego:
<script>
function zmienKlase(x){
var R=document.all?'rules':'cssRules'
document.styleSheets[0][R][0].style.margin=x
}
</script>
<style>
.klasa {margin: 5px; position: relative}
</style>
<div class="klasa">
<a
href="javascript:zmienKlase('100px')">
zmien klase</a>
</div>
Funkcja dla IE/Gecko. W Operze praktycznie nie ma szans na takie
dzialanie. Opera ma znaczne opoznienia w obsludze arkuszy stylow poprzez
DOM.
Swiadcza o tym czerwone 'No'
http://www.opera.com/docs/specs/js/dom/css/
--
BlaTek
Technical Details
Message-ID:
<e4alqh$5ac$1@atlantis.news.tpi.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!mat.uni.torun.pl!news.man.torun.pl!newsfeed.pionier.net.pl!news.nask.pl!news.nask.org.pl!newsfeed.tpinternet.pl!atlantis.news.tpi.pl!news.tpi.pl!not-for-mailReferences:
<e48fnp$s95$1@atlantis.news.tpi.pl> <e4acu6$rk1$1@atena.e-wro.net>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!mat.uni.torun.pl!news.man.torun.pl!newsfeed.pionier.net.pl!news.nask.pl!news.nask.org.pl!newsfeed.tpinternet.pl!atlantis.news.tpi.pl!news.tpi.pl!not-for-mail From: Bogdan Blaszczak <blatek@UsuN-AntyspaMpoczta.wprost.pl> Newsgroups: pl.comp.lang.javascript Subject: Re: zmiana elementu klasy css Date: Mon, 15 May 2006 21:45:50 +0200 Organization: Disorganization Department Lines: 37 Message-ID: <e4alqh$5ac$1@atlantis.news.tpi.pl> References: <e48fnp$s95$1@atlantis.news.tpi.pl> <e4acu6$rk1$1@atena.e-wro.net> NNTP-Posting-Host: ejc98.internetdsl.tpnet.pl Mime-Version: 1.0 X-Trace: atlantis.news.tpi.pl 1147722385 5452 83.15.84.98 (15 May 2006 19:46:25 GMT) X-Complaints-To: usenet@tpi.pl NNTP-Posting-Date: Mon, 15 May 2006 19:46:25 +0000 (UTC) User-Agent: Thunderbird X-Accept-Language: pl, en-us, en In-Reply-To: <e4acu6$rk1$1@atena.e-wro.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit