School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 307,212 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,577 people online right now. Registration is fast and FREE... Join Now!




using javascript with css

 

using javascript with css

seaneyb

2 Nov, 2009 - 12:20 PM
Post #1

New D.I.C Head
*

Joined: 9 Feb, 2009
Posts: 48



Thanked: 1 times
My Contributions
hi everyone,

im just in the design stage of building a website, i have done lots of html xml and java script before however i was just wondering can i encorperate a java script menu in a css style sheet? instead of having to do it in every single webpage making it easier for me to update/modify in the future.

any advice would be appreciated.



User is offlineProfile CardPM
+Quote Post


markhazlett9

RE: Using Javascript With Css

2 Nov, 2009 - 01:12 PM
Post #2

Coding is a lifestyle
Group Icon

Joined: 12 Jul, 2008
Posts: 1,464



Thanked: 48 times
Dream Kudos: 25
My Contributions
Javascript just controls what happens on the site. CSS is just for styling. So of course you can use CSS to style a javascript menu. Just use it inside a div, or use a menu class or ID to style it.

Cheers
User is offlineProfile CardPM
+Quote Post

seaneyb

RE: Using Javascript With Css

2 Nov, 2009 - 01:28 PM
Post #3

New D.I.C Head
*

Joined: 9 Feb, 2009
Posts: 48



Thanked: 1 times
My Contributions
so if i call my div, div menu write the javascript in the css file then link the css to the webpage the menu would be there no problem?
User is offlineProfile CardPM
+Quote Post

iphoneorange

RE: Using Javascript With Css

2 Nov, 2009 - 04:59 PM
Post #4

D.I.C Head
Group Icon

Joined: 20 Aug, 2008
Posts: 147



Thanked: 17 times
Dream Kudos: 75
My Contributions
you can't put javascript in a .CSS file. Like markhazlett said, CSS is for styling things, JS is a scripting language. don't mix the two
User is online!Profile CardPM
+Quote Post

tharam04

RE: Using Javascript With Css

3 Nov, 2009 - 01:16 PM
Post #5

New D.I.C Head
*

Joined: 27 Feb, 2009
Posts: 13



Thanked: 1 times
My Contributions
What you would need to do is create the JavaScript menu and then you can incorporate the CSS in the JavaScript. You can't put JavaScript in CSS, cause it won't work.

To keep from having to do the menu on every page, you can create an external JavaScript file (.js) and then link that file to every page on the website, like how CSS files are linked to a webpage. Then all you would have to do is put the function call on webpage and the name of the external file and it should work.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 09:42PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month