473,386 Members | 1,846 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,386 software developers and data experts.

CSS "id" and "class" syntax in javascript

I have a box defined like this:

Expand|Select|Wrap|Line Numbers
  1. <div id="shadow-container1">
  2. <div class="shadow1">
  3. <div class="shadow2">
  4. <div class="shadow3">
  5. <div class="container">
the innermost "container" is where content appears.

I have to pass the id of "container" to the javascript variable parameter
"target":

Expand|Select|Wrap|Line Numbers
  1. var countries=new ddajaxtabs("source", "target")
How do I replace "target" with the full id of "container", that is what would the correct syntax for "target" be?

I tried many variations but could not come up with one that works, tho this must be a simple one for the experts here.
Jul 6 '09 #1
7 2424
acoder
16,027 Expert Mod 8TB
If it's as you've described, it should be "shadow-container1". If that doesn't work, give a link to the Ajax-tab code that you're using.
Jul 7 '09 #2
acoder,

As "target" has to resolve to "#shadow-container1 .container", the # alone does not work.

I don't understand what you mean by "give a link to the Ajax-tab code that you're using".
Jul 7 '09 #3
acoder
16,027 Expert Mod 8TB
I did a quick search and found that you're using the Dynamic Drive Ajax Tabs. OK, you need to pass the ID, so the easiest way is to give the container a unique ID:
Expand|Select|Wrap|Line Numbers
  1. <div class="container" id="container">
and pass that ID.
Jul 7 '09 #4
So I gave every div in the group a unique ID, doing away with the "class"es alltogether. This made the script happy!

Does this mean id+class combinations cannot be used in JS in general, or is this peculiar to the script in question?

Thank you and cheers.
Jul 7 '09 #5
acoder
16,027 Expert Mod 8TB
They can be used together, but the script required a unique ID. IDs are unique whereas classes are not. Sometimes you want some CSS rule/script to apply to a set of elements, so you use one class for all of them, but you also want to refer to a particular element for some rule and giving a unique ID makes sure of that. You can refer to a particular element without IDs, e.g. by using getElementsByClassName() and then indexing the correct one, but in this case, that wouldn't have worked.
Jul 7 '09 #6
rnd me
427 Expert 256MB
@BobBlock
jQuery supports mixed searches just like css.
Jul 8 '09 #7
@acoder
Thank you again, acorder. Cheers.
Jul 8 '09 #8

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

Similar topics

9
by: Russ Perry Jr | last post by:
I'm using "ID" and "Value" in the generic sense here... Let's say one page I had a <html:select> with a collection like this: <html:options collection="items" property="key"...
32
by: Will Hartung | last post by:
Can someone clarify that multiple classes in the "class" attribute are ok and "legal" and not some fluke? So, I can do: ..pink {color: pink} ..bold {font-weight: bold} ..medium {font-size:...
2
by: yer darn tootin | last post by:
Here's the scenario: I have a javascript function taking the contents of a datalist ( content from a SQL db ) and opening it in a new window to allow the user to print. The pop-up window...
3
by: Jim in Arizona | last post by:
Most of the asp.net learning I've done has been from books that were written during the 1.0 framework. I didn't have a copy of visual studio when I started reading them then I got a hold of VS 2005...
2
by: jain_tj | last post by:
Could anyone please help me with the following problem My xml file is ============== <fig id="F0000001"> <caption>Caption text</caption> <image id="I0000001" image.class="halftone"...
2
by: Angus | last post by:
I am trying to change the selection in Javascript - but this HTML element is not a standard option control. On the web page it looks like a dropdown list - and you click on the right hand down...
1
by: msg2ajay | last post by:
hi, i am working on <div> i have to hide some part of the table. I am not able to hide that table part can anybady tell me where is the error. <html> <head> <script...
4
by: rebeccatre | last post by:
please help me with this, <style> #a, option.message {background-color: green; color: white;} #b, option.message {background-color: yellow; color: black;} </style> <select id="thisselect">...
1
by: gimme_this_gimme_that | last post by:
When an achor tag is defined like this - what might be going on? Why would someone assign the id a value associated with a JavaScript method? Or is something else going on? This comes from a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.