JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 5th, 2012, 01:28 AM
helpneeded22 helpneeded22 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 5 helpneeded22 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 21 m 46 sec
Reputation Power: 0
How to call external css id with JS?

How do I reference an external .css id with JS?

My .css is called: pmstyles.css
My id I want to reference is: rarity-common

Any help would be appreciated. Thanks.

Reply With Quote
  #2  
Old November 5th, 2012, 02:14 AM
Winters Winters is offline
Super Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jul 2003
Posts: 3,874 Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 1 Day 17 h 23 m 53 sec
Reputation Power: 2569
Welcome to DevShed.

I'm not certain what you are asking exactly. You have a style sheet called "pmstyles.css" with a declaration of "#rarity-common".

If you want to dynamically insert the style sheet into the document, you can use something like this.
Javascript Code:
Original - Javascript Code
  1. function importCSS() {
  2.     var ss = document.createElement('link');
  3.     ss.type = 'text/css';
  4.     ss.rel = 'stylesheet';
  5.     ss.media = 'screen';
  6.     ss.href = 'pmstyles.css';
  7.    
  8.     document.head.appendChild(ss);
  9. }
__________________
[PHP] | [Perl] | [Python] | [Java] != [JavaScript] | [XML] | [ANSI C] | [C++] | [LUA] | [MySQL] | [FirebirdSQL] | [PostgreSQL] | [HTML] | [XHTML] | [CSS]

W3Fools - A W3Schools Intervention.

Reply With Quote
  #3  
Old November 5th, 2012, 07:54 PM
helpneeded22 helpneeded22 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 5 helpneeded22 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 21 m 46 sec
Reputation Power: 0
Sorry for the unclear explanation. I am brand new to CSS and Javascript.

Basically I want to change the following text formatting HTML code from HTML to Javascript using CSS to define the font formatting.

Code:
                  
<p align="center">
<font color="#ffffff" size=2 face=Tahoma><b>
<script type="text/javascript">
document.write(mini01[0])
</script>	
</b></font>


I have defined all these elements under the pmstyles.css file under the id: #rarity-common

I have also included at the top of my html doc:
<link rel="stylesheet" type="text/css" href="pmstyles.css">

What is the best way to do this... or is the code you provided the best way to do it?

Thanks.

Reply With Quote
  #4  
Old November 6th, 2012, 02:22 AM
Winters Winters is offline
Super Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jul 2003
Posts: 3,874 Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 1 Day 17 h 23 m 53 sec
Reputation Power: 2569
No, the script I posted is not relevant.
CSS Code:
Original - CSS Code
  1. p#rarity-common {
  2.     text-align: center;
  3.     color: #ffffff;
  4.     font-family: Tahoma, sans-serif;
  5.     font-size: 0.82em;
  6.     font-weight: bold;
  7. }
HTML4Strict Code:
Original - HTML4Strict Code
  1. <p id="rarity-common">
  2.     <script type="text/javascript">
  3.         document.write(mini01[0]);
  4.     </script>
  5. </p>

Last edited by Winters : November 6th, 2012 at 02:36 AM. Reason: typo

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > How to call external css id with JS?

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap