
getAttribute(),setAttribute(), and removeAttribute()
getAttribute()
getAttribute() returns an attribute\'s value. It can be very useful and is really easy to learn.
Here's the syntax:
getAttribute(attribute)
Here is an example for a document that had a table with a width of 300 and an id of "myTable":
The example above would make the variable theTablesWidth be equal to 300 because the table's width was 300.
setAttribute()
setAttribute() changes an attributes value by giving it a new one. It is extremely userful.
Here's the syntax:
setAttribute(attribute,theNewValue) Here is an example for a document that had a table with a width of 300 and an id of "myTable" (the same situation as before) >> The above example would change the table's width to 200. Here is another example for lets say I had a hyperlink with an id of "myLink" that linked to http://ssdesigns.proboards17.com: The above script would make the link that used to go to http://ssdesigns.proboards17.com now go to http://www.solidsnakedesigns.com. removeAttribute() removeAttribute() removes an attribute. It may be useful if you want something to change to the default setting. It's syntax is: removeAttribute(attribute) Here is an example for a document that had a table with a and an id of "myTable" (the same situation as before) >> The above example would remove the table's width attribute, setting it to the default width. Conclusion Combining the powers of getAttribute(), setAttribute(), removeAttribute() can allow you do do some pretty cool things. Maybe you use getAttribute() to get a table\'s width and store it into a variable, and then use setAttribute() to increase the table's width by 100 pixels. Also, beware that there are a few bugs with these methods. Visit http://tinyurl.com/cyp75 for more details. I hope you all enjoyed the tutorial. Happy coding! :)
Here's the syntax:
getAttribute(attribute)
Here is an example for a document that had a table with a width of 300 and an id of "myTable":
The example above would make the variable theTablesWidth be equal to 300 because the table's width was 300.
setAttribute()
setAttribute() changes an attributes value by giving it a new one. It is extremely userful.
Here's the syntax:
setAttribute(attribute,theNewValue) Here is an example for a document that had a table with a width of 300 and an id of "myTable" (the same situation as before) >> The above example would change the table's width to 200. Here is another example for lets say I had a hyperlink with an id of "myLink" that linked to http://ssdesigns.proboards17.com: The above script would make the link that used to go to http://ssdesigns.proboards17.com now go to http://www.solidsnakedesigns.com. removeAttribute() removeAttribute() removes an attribute. It may be useful if you want something to change to the default setting. It's syntax is: removeAttribute(attribute) Here is an example for a document that had a table with a and an id of "myTable" (the same situation as before) >> The above example would remove the table's width attribute, setting it to the default width. Conclusion Combining the powers of getAttribute(), setAttribute(), removeAttribute() can allow you do do some pretty cool things. Maybe you use getAttribute() to get a table\'s width and store it into a variable, and then use setAttribute() to increase the table's width by 100 pixels. Also, beware that there are a few bugs with these methods. Visit http://tinyurl.com/cyp75 for more details. I hope you all enjoyed the tutorial. Happy coding! :)