To get access to a specific element on a webpage, assign it a unique id and use the document.getElementById method to get a reference to it. To access all elements of a certain type, use the getElementsByTagName method to create a reference to the collection of all the elements of that type.
Welcome to Bucaro TecHelp!

Welcome to Bucaro TecHelp!
Maintain Your Computer and Use it More Effectively
to Design a Web Site and Make Money on the Web

About Bucaro TecHelp About BTH User Agreement User Agreement Privacy Policy Privacy Site Map Site Map Contact Bucaro TecHelp Contact Advertise on Bucaro TecHelp Advertise Here RSS News Feeds News Feeds

HTML5 Solutions: Essential Techniques for HTML5 Developers

Essential Techniques for HTML5 Developers

HTML5 brings the biggest changes to HTML in years. Web designers now have new techniques, from displaying video and audio natively in HTML, to creating realtime graphics on a web page without a plugin.

This book provides a collection of solutions to all of the most common HTML5 problems. Every solution contains sample code that is production-ready and can be applied to any project.

Click Here

Accessing Web Page Elements

You can get access to a specific element on a webpage by assigning it a unique id and then using the document.getElementById method to create a reference to that element, as in the example is shown below.

<p id="accessme">You can access this text.</p>

<script language="JavaScript">
var bsize = 1;
function changeSize()
{
  var textref = document.getElementsById("accessme");
  if(bsize) textref.style.fontSize = "20px";
  else textref.style.fontSize = "12px";
  bsize = !bsize;
}
</script>

<input type="button" value="Change Text Size"
onclick="changeSize()"></input>

The example above changes the size of the text in the paragraph when you click on the button.

- You may not be familiar with just creating a free-standing button that is not associated with a form. Actually, by default, it is associated with form[0] in the document's forms collection (assuming it's the first form on the webpage).

To access all elements of a certain type on a webpage, use the getElementsByTagName method to create a reference to the collection of all the elements of that type on the webpage, as in the example is shown below.

<p>You can access this text.</p>

<p>And this text.</p>

<p>And any other text in a paragraph.</p>

<script language="JavaScript">
var bsize = 1;
function changeSize()
{
  var coltext = document.getElementsByTagName("p");

  for(var i = 0; i < coltext.length; i++)
  {
    if(bsize) coltext[i].style.fontSize = "20px";
    else coltext[i].style.fontSize = "12px";
  }
  bsize = !bsize;
}
</script>

<input type="button" value="Change Text Size"
onclick="changeSize()"></input>

The example above changes the size of the text in all paragraphs when you click on the button.

Content is Currency

RSS Feed RSS Feed



Web Design Sections

Modern JavaScript: Develop and Design

This comprehensive beginner’s guide teaches the JavaScript as it is implemented today. The author demonstrates loads of real-world code and makes it available for download. This book includes:

• Easy step-by-step instruction, ample illustrations, and clear examples
• Real-world techniques to build your skills
• Insight into best practices from a veteran Web expert
• Emphasis on strategies for creating reliable code that will work on all of today’s browsers and devices

Click here for more information.


Best Laptop Deals at TigerDirect
[Site User Agreement] [Advertise on This site] [Search This Site] [Contact Form]
Copyright©2001-2011 Bucaro TecHelp 13771 N Fountain Hills Blvd Suite 114-248 Fountain Hills, AZ 85268