Reply
multiple css classes and javascript
Old 05-06-2008, 07:50 PM multiple css classes and javascript
hiptobesquare's Avatar
Extreme Talker

Posts: 162
Location: London UK
hi

i know that 2 classes can be applied to an element like this - <div class='class1 class2'>

the problem i am having is that these divs are generated dynamically with a js function, and the classes are also altered using js but, when i run the page, only one of the styles is applied.

there are divs on my page which are also generated with js but only contain 1class, these are working correctly.

There doesnt seem to be much if any documentation about this online, has anybody experience such a problem?

thanks

mark
hiptobesquare is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 05-06-2008, 08:41 PM Re: multiple css classes and javascript
hiptobesquare's Avatar
Extreme Talker

Posts: 162
Location: London UK
solved it

i am using a class identifier function to apply styles to a whole class, what i hadn't considered was that elements with multiple classes wouldnt get picked up by the function. this works though -

Code:
function setWidth(class,width) { 
  var allPageTags = new Array();  
  var allPageTags=document.getElementsByTagName("*");  
  for (var i=0; i<allPageTags.length; i++) {
    var splitC=new String(allPageTags[i].className).split(' ');
    for (var b=0; b<splitC.length; b++) {  
      if (splitC[b]==class) {  				 
        allPageTags[i].style.width=width+'px';  
}}}}
hiptobesquare is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to multiple css classes and javascript
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.10489 seconds with 12 queries