Title: Access data-id of clicked object, and click another object with same id
Tags: javascript;jquery
Question: I need to click on an object and have it click another object that has the class of the data-id from the first click.
So when someone clicks on the first input with the class of "1stclick" it will then trigger a click of a  2nd input with the class name of the data-id from the first input clicked.
I need it to be dynamic, because there will be multiple sets of inputs per page.
<input class="1stclick" data-id="productNumber"&gt;First Click</input&gt;
<input class="productNumber"&gt;Auto Click Here</input&gt;
jQuery('.1stclick').click(function() {
var productNumber = $(this).data('id');
jQuery(productNumber).trigger("click");
Comment: Your code is dynamic. If you want to have it more generic, just create any new html element with ".1stclick" as class and your click handler will trigger it. You could rename `productNumber`to something for generic like `autoClickElement`

Comment: If you're using inputs then you need to trigger the `focus` event, but that means anytime you click on the `.1stclick` class, the focus shifts to the second one. Then why use the 1st input?



{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 0, 'CommentCount': 2, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2020:00:04/03/20', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<javascript><jquery>', 'Title': 'Access data-id of clicked object, and click another object with same id', 'ViewCount': 46, 'id': 61007137, 'user_AboutMe': None, 'user_AccountId': 18155851.0, 'user_DisplayName': 'RawLIMIT', 'user_Reputation': 1.0, 'user_Views': 1.0, 'user_id': 13207862.0}}