Log in

View Full Version : div id/class not reacting when...



kobo1d
05-07-2010, 08:45 AM
... it is appended to the body by javascript (jquery) !!


well here is the line in my JS


config.$rightnavbutton=$('<div id="resizeme" class="resizeme"><img id="resizeme" class="resizeme" src="'+config.defaultbuttons.rightnav[0]+'"></div>').css({zIndex:50,position:'absolute',left:config.offsets.left+config.$gallery.get(0).offsetWidth+config.defaultbuttons.rightnav[1]+'px',top:config.offsets.top+config.defaultbuttons.rightnav[2]+'px',cursor:'hand',cursor:'pointer'}).attr({title:''}).appendTo('body')


as you can see i put the div and img into id and class (for testing purpose) but if i try to manipulate that stuff via my style.css, it isnt reacting....


this is a part of my stylesheet which should work in a normale case


#resizeme img {
width:40;
}
#resizeme img:hover {
width:47;
}


but it doesnt work... my css is ignored when ther page loads...

anybody got any idea plz and can point me to what is going on here..



THX :o

Deadweight
05-07-2010, 12:02 PM
for one u cant have a class and an id in the same tag >.<

Deadweight
05-07-2010, 12:03 PM
also you messed up
.resizeme img {
width:40;
}
#resizeme img:hover {
width:47;
}

# = id
. = class

kobo1d
05-07-2010, 12:17 PM
for one u cant have a class and an id in the same tag >.<

sure i can ;)

if it's nice code or not, is another question... but still, this is not the problem since i tried different possibilities and it works for other divs not appended by JS... (id+class)

@ Crazykld69

that also didnt work...


and i allready tried every possible way before i made my post...
id only, class only, on either div or img and both, mixed etc...

thats why i wrote in my first post "(for testing purpose)"


but thx anyways for ya posts..



i still think it has todo with the JS, since its only appended to the body and not really "there"...
if i check my source-code in the loaded page @ browser, i dont even see the code/tag for this image.. but it is there, just appendeed by JS...

see what i mean ?!

Deadweight
05-07-2010, 12:32 PM
oh u have it in a JS?
then nope i dont think you can do that.
not sure but move this to the javascript fourm

vanquisher
05-08-2010, 01:54 PM
Hello Sir,

Can you please show me both the files where you are facing problem? If possible, please also tell me your email so that I will send the corrected code to your emai.

Thank You

kobo1d
05-12-2010, 09:01 AM
the JS Code is the .js from this script -> http://www.dynamicdrive.com/dynamicindex4/stepcarousel.js

and around this part:


<img src="'+config.defaultbuttons.rightnav[0]+'">

i tried to manipulate the image with a css so that on hoover the size is changing..


so i changed it to:


<img id="resizeme" src="'+config.defaultbuttons.rightnav[0]+'">

with this css:


#resizeme {
width:40;
}
#resizeme:hover {
width:47;
}

but it didnt work... (ignored)


thx for any hints! ;-)

zip222
05-12-2010, 06:04 PM
An element can certainly have both a class and an id assigned to it. An element can also have multiple classes assigned to it. But an element can only have one ID.

kobo1d
05-15-2010, 02:40 PM
i got this solved by just appending another piece of css-code in the jquery hover function instead of manipulating the external stylesheet...
everything inside the JS-Code...

(resolved)