Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Hands-on JavaScript for Python Developers

You're reading from  Hands-on JavaScript for Python Developers

Product type Book
Published in Sep 2020
Publisher Packt
ISBN-13 9781838648121
Pages 410 pages
Edition 1st Edition
Author (1):
Sonyl Nagale Sonyl Nagale
Profile icon Sonyl Nagale

Table of Contents (26) Chapters

Preface 1. Section 1 - What is JavaScript? What is it not?
2. The Entrance of JavaScript into Mainstream Programming 3. Can We Use JavaScript Server-Side? Sure! 4. Nitty-Gritty Grammar 5. Data and Your Friend, JSON 6. Section 2 - Using JavaScript on the Front-End
7. Hello World! and Beyond: Your First Application 8. The Document Object Model (DOM) 9. Events, Event-Driven Design, and APIs 10. Working with Frameworks and Libraries 11. Deciphering Error Messages and Performance Leaks 12. JavaScript, Ruler of the Frontend 13. Section 3 - The Back-End: Node.js vs. Python
14. What Is Node.js? 15. Node.js versus Python 16. Using Express 17. React with Django 18. Combining Node.js with the Frontend 19. Enter Webpack 20. Section 4 - Communicating with Databases
21. Security and Keys 22. Node.js and MongoDB 23. Putting It All Together 24. Assessments 25. Other Books You May Enjoy

Using selectors

So far, we've only been using console.log and alerts and prompts to input and output information. While these methods are useful for testing, they're not exactly what you would use in everyday life. Most of the web applications that we use, from searching to email, use the DOM to interact with the user to get input and show information. Let's take a look at a small example: https://github.com/PacktPublishing/Hands-on-JavaScript-for-Python-Developers/tree/master/chapter-6/hello.

If you open the HTML in the browser, we see a very simple page:

Figure 6.1 Our basic page

If we click the button, we don't get an alert or a console message, but instead, we have this:

Figure 6.2 An in-page response to our click!

Yay! It's our first instance of DOM manipulation.

DOM manipulation explained

Let's look at the JavaScript that powered that amazing example:

document.querySelector('button').addEventListener('click', (e) => {
document...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}