Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
added 2 characters in body; edited tags
Source Link
Tasos K.
  • 8.1k
  • 7
  • 44
  • 68

In jQuery i have the following code

$("li#credit").trigger('click'); 

This code triggers the click event only on li that has id credit.

Now to do this using JavaScript

document.querySelectorAll("li#credit").click(); 

I am getting the error:

click() is not a function

The page I am working have multiple elements with id "credit"id="credit", I need to trigger a click event only on <li> that has id credit.

In jQuery i have the following code

$("li#credit").trigger('click'); 

This code triggers the click event only on li that has id credit.

Now to do this using JavaScript

document.querySelectorAll("li#credit").click(); 

I am getting the error:

click() is not a function

The page I am working have multiple elements with id "credit", I need to trigger a click event only on <li> that has id credit.

In jQuery i have the following code

$("li#credit").trigger('click'); 

This code triggers the click event only on li that has id credit.

Now to do this using JavaScript

document.querySelectorAll("li#credit").click(); 

I am getting the error:

click() is not a function

The page I am working have multiple elements with id="credit", I need to trigger a click event only on <li> that has id credit.

Post Closed as "Duplicate" by Quentin html
Minor post formatting
Source Link
Tasos K.
  • 8.1k
  • 7
  • 44
  • 68

How to trigger click event using javascriptJavaScript on querySelectorAll

In jqueryjQuery i have the following code

$("li#credit").trigger('click');

$("li#credit").trigger('click'); 

This code triggers the click event only on li that has id credit.

Now to do this using javascriptJavaScript

document.querySelectorAll("li#credit").click(); 

I am getting the error click() is not a function:

click() is not a function

The page I am working have multiple elements with id "credit", I need to trigger a click event only on li<li> that has id credit.

How to trigger click event using javascript on querySelectorAll

In jquery i have the following code

$("li#credit").trigger('click');

This code triggers the click event only on li that has id credit.

Now to do this using javascript

document.querySelectorAll("li#credit").click(); 

I am getting error click() is not a function

The page I am working have multiple elements with id "credit", I need to trigger a click event only on li that has id credit.

How to trigger click event using JavaScript on querySelectorAll

In jQuery i have the following code

$("li#credit").trigger('click'); 

This code triggers the click event only on li that has id credit.

Now to do this using JavaScript

document.querySelectorAll("li#credit").click(); 

I am getting the error:

click() is not a function

The page I am working have multiple elements with id "credit", I need to trigger a click event only on <li> that has id credit.

Source Link
Jagan K
  • 1.1k
  • 3
  • 16
  • 39

How to trigger click event using javascript on querySelectorAll

In jquery i have the following code

$("li#credit").trigger('click');

This code triggers the click event only on li that has id credit.

Now to do this using javascript

document.querySelectorAll("li#credit").click(); 

I am getting error click() is not a function

The page I am working have multiple elements with id "credit", I need to trigger a click event only on li that has id credit.