New Feature: Playlist Center! Pick a topic and let our playlists guide the way.

Start learning with our library of video tutorials taught by experts. Get started

Dreamweaver CS5.5 New Features
Illustration by

DOM element hinting


From:

Dreamweaver CS5.5 New Features

with James Williamson

Video: DOM element hinting

If you've spent any amount of time hand-coding sites, you understand that often it's the little things that mean a lot. So Dreamweaver's new code hinting for DOM element scripting may seem minor at first, but it's something that can really speed up your JavaScript coding. Let's take a look at how it works. So I have the resources.htm open from the 02_05 folder. Now, the first thing I want to point out is that I have a link to a JavaScript file called hinting_test.js in the code of my document.

Watch this entire course now—plus get access to every course in the library. Each course includes high-quality videos taught by expert instructors.

Become a member
please wait ...
Dreamweaver CS5.5 New Features
1h 50m Intermediate May 02, 2011

Viewers: in countries Watching now:

This course covers the enhancements to the latest release of Adobe's web design and development software. Author James Williamson examines Dreamweaver's updated support for current Web standards, such as code hinting for HTML5, CSS3, and jQuery, and new W3C-compliant code validation. James also demonstrates the new features introduced specifically for mobile development that allow developers to download, install, and configure native applications for Android and Apple iOS. These features include support for PhoneGap integration, jQuery mobile framework, native binaries, and platform emulators launched directly in Dreamweaver.

Topics include:
  • Creating new HTML5 documents
  • Using code hinting for CSS3, HTML5, DOM elements, and jQuery
  • Configuring jQuery widgets with the Widget Browser
  • Managing media queries
  • Previewing web pages on multiple devices with the Multiscreen Preview panel
  • Configuring mobile application frameworks
  • Building and emulating mobile applications
Subject:
Web
Software:
Dreamweaver
Author:
James Williamson

DOM element hinting

If you've spent any amount of time hand-coding sites, you understand that often it's the little things that mean a lot. So Dreamweaver's new code hinting for DOM element scripting may seem minor at first, but it's something that can really speed up your JavaScript coding. Let's take a look at how it works. So I have the resources.htm open from the 02_05 folder. Now, the first thing I want to point out is that I have a link to a JavaScript file called hinting_test.js in the code of my document.

So if I switch over to Source Code and scroll up, you guys can see there is the link to my external script file. Okay. So I am going to switch over to hinting_test.js. And the reason that I externalized this JavaScript is not only is that usually a good idea, but it's also going to show you that Dreamweaver will go ahead and introspect documents that are linked to this and provide different IDs and class names for us from the parent document. So here I have a function called changeColor, and it's fired when the page is loaded, so I am just going to go ahead and place my cursor inside the function brackets, and I am going to start by creating a variable.

So, var targetElement, and I need to go ahead and set this value. Now, I want to target specific elements on the page, and I want to target any element that has an ID of pageID. So to do that, I am going to type in 'document' and my code hinting comes up, and now I want to do getElementById, so I can just type in 'get' and I am going to let code hinting handle the rest of this for me. So if I hit Return or Enter, it will finish that for me, and now I need to go ahead and give it an ID. Now, what if I don't have all the IDs in my parent document memorized? Well, if I type in a quotation mark, I now get a list of all of the IDs in my parent file.

This is really cool! So I can scroll down through the list and I can find pageID, because remember, that's the one we're looking for. If I hit Return or Enter, now all I have to do is close my parentheses and type in a semicolon. All right! Now, we need to go ahead and change its color, so I'm going to go down to the next line and I'm going to type in 'targetElement.style.color = "red"'. All right, cool! So code hinting helped with that entire process, but the really cool thing there was going out to my parent page and grabbing the pageID from the code.

So I'm going to go ahead and save that, and then I want to preview this in a browser, and when I do that, I can see the element that has the pageID is now red. So let's go back in our code, and let's check out some of the other code hinting improvements that have been made. So the next thing I want to do is I want to get rid of this getElementById, and let's try getting elements by their tag name. So I'm going to type in 'document.getElementsByTagName', and now when I type in a single quote, I get an entire list of HTML elements.

This is the same list that you get when you're hand-coding in Dreamweaver in just a normal HTML document, so they've added that as well. And now I just want do maybe all heading 1s. So I'm going to do h1 and hit Return and then close my parentheses. Now, obviously we're going to get more than one of those, so I need to create a for loop that's going to loop through them and apply the color to each one of these. So just on top of my target element, I'm just going to go ahead and create a loop. So I am going to do for(var i=0; and I am going to make i

Now, I am going to ahead and place the style assignment inside my for loop. And of course I need to reference each item in the array that's returned, so I'm just going to go ahead and in bracket notation pass i in. Okay. So now let me go ahead and save this and preview this in the browser as well. And now if I scroll down, I can see that all the heading 1s on the page are now red. Perfect! Now, in addition to giving you a list of tags and giving you a list of IDs, it will also introspect all of your class names from your file as well.

So I now want to go ahead and get rid of my getElementsByTagName, and I'm going to change that to getElementsByClassName. Now, if you're wondering, it does support both the document.getElementsByClassName as well as the element.getElementsByClassName, so it will work both ways. Again, if I type in a single quotation mark, now I get all of the classes in my document. I can see that I can just scroll through all of them. And I'm just going to do accent, the first one that comes up. And now I'll close my parentheses, and we shouldn't need to change anything down here.

So I'm going to go ahead and save that, preview that in the browser, and now you can see that only where the accent class has been applied, which has been applied to this header and this header, is red. Cool! So this code hinting works for getElementById, getElementsByName, getElementsByTagName, and getElementsByClassName. What this really means more than anything else is that when you're scripting, you're going to be able to speed up the process of targeting elements on your pages, even when you're working in remote files. Dreamweaver's ability to introspect those pages and then return elements and their IDs and then classes will really just end up being one more of those little things that Dreamweaver does to help speed up your development process.

Find answers to the most frequently asked questions about Dreamweaver CS5.5 New Features.


Expand all | Collapse all
please wait ...
Q: This course teaches us how to create mobile app in the "Mobile App Support" chapter and the app works great. But when we try to upload to android market, it says that the Android Market can't upload a debug/release version. What's wrong with the app?
A: As mentioned in the movie, the Dreamweaver emulator support does not create deliverable apps. It is designed to act as an IDE and debugging environment only. From there it is up to the developer to package and distribute apps to the various app stores.

Take a look at https://build.phonegap.com/. It's an early service dedicated to creating deliverable binaries for multiple platforms. Since it's PhoneGap, it's also the same framework used within Dreamweaver, so Dreamweaver based apps should port right over.
 
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.
Upgrade now


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

join now Upgrade now

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Dreamweaver CS5.5 New Features.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.