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

Can someone explain this code line to me?

Hi everyone, I am relatively new to JS and I am hoping someone could
tell me what this line of codes mean. This was written by some
brilliant guys at webfx and I am trying to understand some of their
codes.

To begin with I don't understand how this variable is set.

var sliderE1=document.getElementByID?
document.getElementById("slider-1"): null;

Question 1: What is the function of the "?" mark after the
document.getElementByID
Question 2: What is the reason for including ": null"
and Question 3: Can't this be done just by simply using
"document.getElementById("slider-1")"?

Thanks in advance.

Jul 23 '05 #1
1 1347
wrote on 03 apr 2005 in comp.lang.javascript:
Hi everyone, I am relatively new to JS and I am hoping someone could
tell me what this line of codes mean. This was written by some
brilliant guys at webfx and I am trying to understand some of their
codes.

To begin with I don't understand how this variable is set.

var sliderE1=document.getElementByID?
document.getElementById("slider-1"): null;

Question 1: What is the function of the "?" mark after the
document.getElementByID
Question 2: What is the reason for including ": null"
var condition = false
var a = (condition) ? "This is true" : "This however is false"
alert(a)

will show: This however is false

var condition = true
var a = (condition) ? "This is true" : "This however is false"
alert(a)

will show: This is true

=========================================
and Question 3: Can't this be done just by simply using
"document.getElementById("slider-1")"?


(document.getElementByID)

is only true in browsers that support it.
in other [read older] browsers:

var sliderE1 = document.getElementById("slider-1")

would give an error and the js would stop.

========================================

Your first questions are so basic,
that I suppose you did not read any javascript tutorial before asking.

<http://www.google.com/search?q=javascript.tutorial>

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Maciej Nadolski | last post by:
Hi! I can`t understand what php wants from me:( So: Cannot send session cache limiter - headers already sent (output started at /home/krecik/public_html/silnik.php:208) in...
8
by: Igor Raytsin | last post by:
Hello All, The following script is reproducing the problem assuming you have Northwind database on the server. Please note it gives you the error message on line 12. USE tempdb GO...
5
by: J Allen Horner | last post by:
I'm just starting to learn C, and the tutorial I'm reading uses this code as an example: ----------- #include <stdio.h> #define MAX 10 int a; int rand_seed=10;
6
by: amerar | last post by:
Hi All, I'm not good at Javascript, so I am trying to understand this small bit of code: var groups=document.$fm.category.options.length; var group=new Array(groups); for (i=0; i<groups;...
1
by: td0g03 | last post by:
Hello, I am new to C and I am new to English. I not sure what palindromes mean. I don't know exactly what my teacher wants me to do. If someone could explain it to me in a different way that would be...
1
by: mansa | last post by:
a) A company receives hundreds of orders every week through the mail. Explain carefully how BATCH- PROCESSING might be used. Describe the role of the BATCH TOTAL in this process. Explain how batch...
3
by: Aarti | last post by:
Hi, Can some one please explain why the output of this program is 15 #include <iostream> using namespace std; class A {
7
by: Mike Kent | last post by:
It's often useful for debugging to print something to stderr, and to route the error output to a file using '2>filename' on the command line. However, when I try that with a python script, all...
1
by: okonita | last post by:
I need major help resolving a UDF error. My environment id DB2 UDBv8.2 and v9.1 on a Linux and Windows server. I am getting a SQL20148N error which states as follows: SQL20148N Routine...
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.