/    Sign up×
Community /Pin to ProfileBookmark

javascript and css, div

I have the following javascript

[CODE]function i33020001() {
document.getElementById(‘photogallery’).innerHTML='<img id=”gallery” src=”Pictures/33020001.jpg” />’;
}[/CODE]

This code works but it is required to see my issue.

I have this div

[CODE]<div id=”photogallery”></div>[/CODE]

In my (external) css i have

[CODE]img.gallery {width:100px;}[/CODE]

How do i get it to actually use that css, it seems like css and javascript don’t like working together. I have tried all the following different css but none of them worked either.

[CODE].photogallery {width:100px;}
.photogallery > img {width:100px;}[/CODE]

I would prefer to be able to use css instead of setting it per picture inside its tag. Anyone have any ideas?

Also, I wasnt sure which to put this in, css or javascript. Since it is actualy the css that seems like the problem, i posted here.

to post a comment
CSS

3 Comments(s)

Copy linkTweet thisAlerts:
@cootheadSep 11.2008 — Hi there jonthegamer,

this...
[color=navy]img.gallery {width:100px;}[/color]
...should be...
[color=navy]img[color=red]#[/color]gallery {width:100px;}[/color]
...to work with...
[color=navy]&lt;img[color=red] id="gallery"[/color] src="Pictures/33020001.jpg" /&gt;[/color]
[i]coothead[/i]
Copy linkTweet thisAlerts:
@jonthegamerauthorSep 11.2008 — wow... i thought a "#" was for a class. I use a "." or every other id tag i have and it works fine.

btw that did work but im still confused
Copy linkTweet thisAlerts:
@cootheadSep 11.2008 — Hi there jonthegamer,
[color=navy]I use a "." for every other id tag I have and it works fine.[/color][/quote]
I bet that you can walk on water also. ?

[i]coothead[/i]
×

Success!

Help @jonthegamer spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.12,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...