Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
|
all DOM objects have a style object. Every style object has properties which represent CSS styles. Styles with dashes in them must be expressed in camelCase, because JavaScript does not allow dashes in property names (a dash would indicate subtraction).
Any time you have a DOM object, you could change its display like this:
Code:
domObject.style.display = "none";
The most common way to create a DOM object is with document.getElementById. The above example could become:
Code:
var domObject = document.getElementById("my-elements-id");
domObject.style.display = "none";
now, the variable domObject is a reference to the HTML element with an id="my-elements-id", and can be manipulated.
The way I did it in my example will not help you. If you're interested in seeing the code, it may be found here, among other things: http://wayfarerweb.com/js/common.js
See the line which reads:
Code:
$("#hide-ad").click(function() {$("#link-unit, p:has(#hide-ad)").hide(); return false;})
What you're looking at is jQuery code, which relies on the popular library. It is basically a quicker way of selecting and manipulating things.
|