CSS Question Bank For UT2 by JN
CSS Question Bank For UT2 by JN
CSS Question Bank For UT2 by JN
Types of cookies:
1. Session Cookies
2. Presistent Cookies
Properties:
o document.title: Gets or sets the title of the document.
o document.body: Represents the <body> element of the
document.
o document.head: Represents the <head> element of the
document.
o document.URL: Returns the URL of the document.
o document.cookie: Gets or sets cookies associated with the
document.
Methods:
o document.getElementById(id): Returns the element with the
specified ID.
o document.getElementsByClassName(className): Returns a
collection of elements with the specified class name.
o document.getElementsByTagName(tagName): Returns a
collection of elements with the specified tag name.
o document.querySelector(selector): Returns the first element
that matches the specified CSS selector.
o document.querySelectorAll(selector): Returns a collection of
elements that match the specified CSS selector.
o document.createElement(tagName): Creates a new
element with the specified tag name.
o document.createTextNode(text): Creates a new text
node with the specified text.
Diagram of document :
The pixel along the horizontal axis of the element that you
want displayed in the upper left.
yCoord
The pixel along the vertical axis of the element that you
want displayed in the upper left.
options
An object containing the following properties:
top
Specifies the number of pixels along the Y axis to scroll the
window or element.
left
Specifies the number of pixels along the X axis to scroll the
window or element.
behavior
Determines whether scrolling is instant or animates
smoothly. This option is a string which must take one of the
following values:
smooth: scrolling should animate smoothly
instant: scrolling should happen instantly in a single
jump
auto: scroll behavior is determined by the computed
value of scroll-behavior
EXAMPLE :
JS
element.scrollTo(0, 1000);
Using options:
JS
element.scrollTo({
top: 100,
left: 100,
behavior: "smooth",
});
To scroll up:
window.scrollBy(0, -window.innerHeight);
Using options:
window.scrollBy({
top: 100,
left: 100,
behavior: "smooth",
});
Unit 5:
1. What is regular expression? Explain with
example.
ANS : Regular expression (regex) is a sequence of
characters that define a search pattern. It is used to search,
edit, or manipulate text and data. Regex is used in many
different programming languages and text editors.
1. Literal Characters:
o Matches exact characters, e.g., /a/ matches "a".
2. Special Characters:
o . matches any character except newline.
o \ escapes special characters, e.g., \. matches a literal dot.
3. Character Classes:
o [abc]: Matches any one of the characters a, b, or c.
o [^abc]: Matches any character except a, b, or c.
o [a-z]: Matches any lowercase letter.
o [0-9]: Matches any digit.
4. Predefined Classes:
o \d: Any digit.
o \D: Any non-digit.
o \w: Any word character (alphanumeric + underscore).
o \W: Any non-word character.
o \s: Any whitespace character.
o \S: Any non-whitespace character.
5. Anchors:
o ^: Start of string.
o $: End of string.
6. Quantifiers:
o *: 0 or more times.
o +: 1 or more times.
o ?: 0 or 1 time.
o {n}: Exactly n times.
o {n,}: n or more times.
o {n,m}: Between n and m times.
7. Grouping & Alternation:
o (abc): Groups abc.
o a|b: Matches a or b.
Flags
g: Global search.
i: Case-insensitive.
m: Multi-line.
s: Dot matches newline.
u: Unicode.
y: Sticky.
ANS. :