473,322 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Change CSS(Class attribute to other attribute)

I have surf throught many site and found this...
[HTML]http://www.adobe.com/go/gn_home[/HTML]
how to change an element attribute to other class attribute...
I wonder......can we change class attribute to something else..
i need to change class that have[code].DisplayBlock {
display : block;
}
CODE] to
Expand|Select|Wrap|Line Numbers
  1.  .DisplayNone {
  2.       display: none;
  3.      }
  4.  
by vbscript or javascript for some function that i need
Nov 6 '08 #1
5 7073
DrBunchman
979 Expert 512MB
Hi MATTXtwo,

You can use Javascript to do this, like so:

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3.     <style>
  4.         .DisplayBlock {
  5.               display : block;
  6.             }
  7.  
  8.         .DisplayNone {
  9.               display: none;
  10.              }
  11.  
  12.     </style>
  13.     <script type="text/javascript">
  14.         function Hide(element)
  15.         {
  16.         document.getElementById(element).className = 'DisplayNone';
  17.         }
  18.         function Show(element)
  19.         {
  20.         document.getElementById(element).className = 'DisplayBlock';
  21.         }
  22.     </script>
  23. </head>
  24. <body>
  25.     <div id="div1" class="DisplayBlock" OnMouseOver="Hide('div1')" OnMouseOut="Show('div1')">
  26.         Hello World!
  27.     </div>
  28. </body>
  29. </html>
Let me know if this helps,

Dr B
Nov 6 '08 #2
Hi MATTXtwo,

Let me know if this helps,

Dr B
Sorry Dr B
Expand|Select|Wrap|Line Numbers
  1. function changeBMBI(vtype)
  2. {    var x=1;
  3. //var set as many of label element that need to be control
  4.     if(vtype=="BM")
  5.     {    
  6.         document.getElementById("BI"+x).style.display="none";
  7.         document.getElementById("BM").style.display="none";
  8.         document.getElementById("BM"+x).style.display="block";
  9.         document.getElementById("BI").style.display="block";
  10.         alert(vtype=="BM"+"bm");
  11.     }else{
  12.     alert(vtype=="BM"+"not"+vtype);
  13.     }
  14.     if(vtype=="BI")
  15.     {    document.getElementById("BM"+x).style.display="none";
  16.         document.getElementById("BI").style.display="none";
  17.         document.getElementById("BI"+x).style.display="block";
  18.         document.getElementById("BM").style.display="block";
  19.         alert(vtype=="BI"+"bi");
  20.     }else{
  21.     alert(vtype=="BI"+"not"+vtype);
  22.     }
  23. }
  24. ..................................................................................................................
  25. <label id="BM1"><b>Bahagian Sumber Manusia</b></label>
  26. <label id="BI1"><b>Human Resource Department</b></label></font></td>
  27. </tr><tr><td align="right">
  28. <label id="BI" onclick="javascript: changeBMBI('BI')">versi Bahasa Inggeris</label>
  29. <label id="BM" onclick="javascript: changeBMBI('BM')"><b>Malay version</b></label></td>
  30. </tr><tr><td><input id="versions" type="hidden" value="<%=session("versiBMBI")%>"><%Response.Write session("versiBMBI")%></td>
  31.  
it's for changing between to language ..
The thing is we can only change the style by element not by class declare on all element or div id's for bulk element change from style display block to style display none
Nov 6 '08 #3
DrBunchman
979 Expert 512MB
Sorry MATTXtwo, I don't understand what it is your trying to do or why the example I gave above won't work.

I thought that you wanted to be able to change the class of an element programatically - was I wrong?

Dr B
Nov 6 '08 #4
Sorry MATTXtwo, I don't understand what it is your trying to do or why the example I gave above won't work.

I thought that you wanted to be able to change the class of an element programatically - was I wrong?

Dr B
it works fine....it just I thought it would be done like change the class definiton from style:display block to style:display none..
so i added the x var as for the id like BM,BM1,BM2 and so on
Thanks anyway
Nov 7 '08 #5
DrBunchman
979 Expert 512MB
Ah I see! I don't think that's possible using javascript but if any other experts know different then please let us know.

I'm glad that it works for you anyway :-)

Dr B
Nov 7 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: D. Alvarado | last post by:
I was wondering what the appropriate CSS attribute name and value are for strike-through text, and how widely this attribute is supported? Thanks, - Dave
10
by: Harry Haller | last post by:
How can I change the value in a css class? For instance, with I.E., I want to change the value in the class span.arr from middle to 0.2em. The value of middle is OK for most other browsers. I...
2
by: Linus Martinsson | last post by:
How can I change attribute in html elements from my aspx.cs page? For example if I want to change the src-attribute in an iframe. //Linus
2
by: Alfred Salton | last post by:
Can anyone show me how to set the css class of an HtmlTable control in code on the server? I can't find any indication that the css class is a property of the HtmlTable, HtmlTableRow and...
2
by: dave | last post by:
Guys, I have got a table on my usercontrol and I am trying to apply a css class to one of its cell. The roblem is when I specify the class name in the class property of the cell it does not...
9
by: Will | last post by:
I have given up looking for a solution so I figured I would break down and ask. I am trying to modify a CSS class in page_load. I have no problem doing it with an ID with the simple ...
2
by: PJ6 | last post by:
Is there a way of specifying the CSS class of all cells within a table without having to set the class attribute for each cell individually (server-side or client-side)? Paul
2
by: Steve | last post by:
Anyone have an example of getting and setting an attribute of a CSS class defined at the top of an HTML page? Thanks in advance
1
by: ppioter | last post by:
hi this regards asp.net 1.1 I have following problem I would like to change attribute of <LINKtag via ASP I have this definition inside <HEADsection of my aspx file <LINK id="stylesheet"...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.