473,381 Members | 1,451 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,381 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 12568
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.