Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



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

Posts: 186
Location: London UK
Trades: 0
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
 
 
Register now for full access!
Old 05-06-2008, 09:41 PM Re: multiple css classes and javascript
hiptobesquare's Avatar
Extreme Talker

Posts: 186
Location: London UK
Trades: 0
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 Search this Thread
Search this Thread:

Advanced Search

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

BB 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.24518 seconds with 12 queries