473,396 Members | 1,921 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Getting NULL when trying to use queryselector to fetch dom elements

24 Expert 16bit
I keeping getting NULL when using queryselector to fetch DOMelements that have been created after the site has loaded.

Does anyone know why this happens?

The first selector clicks on the menu
The second selector clicks on the menu option that only loads and gets added to the DOM after the first is clicked

1) site loads
2) i run the following code to fetch dom elements via the web developer console
Expand|Select|Wrap|Line Numbers
  1.  
  2. function fetchElement(){
  3.     document.querySelectorAll('[data-menu="menu"]')[0].click()
  4.     document.querySelectorAll('[data-option="menuitem"]')[0].click()
  5. }
  6. fetchElement()
  7.  
The second click returns null.

I am wondering if it's because those menuitems get added to the DOM after the first click? So it's not actually there, but if that's the case how would I access those elements?


Thank You,
DT
Apr 28 '22 #1
1 12572
dev7060
636 Expert 512MB
Post the specific/minimum code able to reproduce the error.
May 2 '22 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: dipesh | last post by:
I am getting error when trying to Add Web Reference in Visual Studio 2005. "Some of the files required for web references are not installed"
5
by: comp.lang.php | last post by:
// NEW 11/27/2006: FINALLY, IF YOU ADDED OR DELETED OR DID ANY KIND OF FORM ACTION SUCCESSFULLY, DON'T RE-DISPLAY THE NEW EXPENSE ITEMS VIA $_POST if ($_POST && (!is_array($leaseObj->errorArray)...
1
by: Developer | last post by:
Dear Group Member, I am sorry if I have posted this query in wrong group, but since this is connected with ASPO.NET2.0, thought of posting here. I am doing a very simple program where I am...
1
by: sshankar | last post by:
Hi, New to Stored procedure. Basically just installed DB2 v8.1.0.36 Was trying to build a stored procedure.. It is giving following error.. Looks like some error related to configuration...
5
by: Emmi | last post by:
Hi there, just starting in PHP and found some code that would switch out pages depending on link clicked. It worked great loading different pages. Then I thought I would try the same code by...
1
by: jonny | last post by:
Went from using Visual Web Develop express to Visual Studio 2005 and getting error when trying to open project. Error message: "One or more projects in the solution could not be loaded for the...
1
by: =?Utf-8?B?QmFydA==?= | last post by:
When I try to run my compiled console application on a Win 2k3 server, I am getting the following error: Unhandled Exception: System.IO.FileNotFoundException: Could not load file or ass embly...
7
by: IntelliOfficer | last post by:
Hi all, This is my first post, well, ever... So here it goes. I'm writing a chunk of code that finds an email address in a table, then places it into the SendObject method. When I try to run...
0
by: raman2ss | last post by:
Hi All, I have added a dropdownlist to the datagrid at runtime. Dim DropDownList1 As New DropDownList DropDownList1 .Items.Add("R") DropDownList1 .Items.Add("D") ...
0
by: acgvelarde | last post by:
Hi, Please help me, I am getting MemoryError when trying to fetch a specific email. This is the error message: python(24622,0x1888c00) malloc: *** vm_allocate(size=3309568) failed (error...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.