TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Javascript, AJAX, E4X (http://www.talkphp.com/javascript-ajax-e4x/)
-   -   access css thorugh javascript (http://www.talkphp.com/javascript-ajax-e4x/2376-access-css-thorugh-javascript.html)

freenity 02-29-2008 02:39 PM

access css thorugh javascript
 
Hi
To access this:

[/code]#bla
{
display: none;
}[/code]

I just do: document.getElementById('bla').style.display =

But How do I access something ilke this:
Code:

#.treeview #bla ul li
{
    display: none;
}

:-/ ??

Wildhoney 02-29-2008 03:18 PM

I've found that Javascript cannot override items found in CSS files. To do that you'll have to set the display: none in the style attribute of the element. That way Javascript will be able to override it.

freenity 02-29-2008 03:20 PM

ok thanks.

flyingbuddha 02-29-2008 04:35 PM

#. isn't valid, is it? :s
Code:

var o = document.getElementById('bla');
var list_items = o.getElementsByTagName('li');
if(list_items.length){
    var item_css;
    for(var i=0;i<list_items.length;i++){
        item_css = list_items[i].style;
        alert(item_css.display);
    }
}



All times are GMT. The time now is 11:40 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0