Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

What is Unobtrusive JavaScript and DOM Scripting?

0
Posted

What is Unobtrusive JavaScript and DOM Scripting?

0

Rather than hardcoding event handlers as HTML attributes, unobtrusive JavaScript assigns them using the DOM. Well-structured, valid HTML is a prerequisite to DOM scripting. Documents should declare a DOCTYPE, they should validate against the DOCTYPE, and presentational styles should be applied with CSS (read “should” as “life will be easier for everyone if you do”). Use a few targeted CSS ID and class selectors to define page layout. Don’t go overboard on defining selectors, remember, descendent selectors are your friend. I’ll use a simple text-based rollover for demonstration purposes. In a perfect world, with perfect browsers, this effect would be created using the CSS pseudo hover class but, as you’ve probably guessed, it doesn’t work in Internet Explorer 6. Here’s a screenshot of what we’re building.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123