0

I'm developing a kind of online store in which adding items to carts are carried out by an Ajax method. I'm using ASP.NET MVC and in my Razor view engine I Require to have many submit buttons with the same ID (for some reasons) but with different names to distinguish them problematically. These buttons are used to fire the Ajax method at different areas in the same page. When they are clicked, they set some value to a hidden submit button (the ones that share the same ID) and then fire them. I need to fire these button based on their names, for example

 //Instrad of 
 $("#ID").trigger("Click")     
 //I trigger click them by their `name` attribute. 

I know how to get the values or other attributes of an element by name, but so far I have no clue on how to trigger a button by name. So I wanna know if that's possible at all and how it can be done.

1 Answer 1

3

Try below

$("button[name='btnName']").trigger("Click");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.