I'm trying to make this possible:
Is there a way or an if statement to call this
$('#add-remove-buttons').find('.button').trigger('click');
After it detects that the #add-remove-buttons is present on the webpage?
-Thanks
I'm trying to make this possible:
Is there a way or an if statement to call this
$('#add-remove-buttons').find('.button').trigger('click');
After it detects that the #add-remove-buttons is present on the webpage?
-Thanks
 
    
    try first check first element exist or not Check if element exists in jQuery after fire the event after exist
 if ($("#add-remove-buttons").length > 0)
 { 
    $("#add-remove-buttons").trigger('click');
 }
 
    
     
    
    Whe you insert $('#add-remove-buttons').trigger('click'); statement after the click handler on button then if the button exists it will trigger the action. You need not explicitly check to see if it exists
$(function(){
  
  $('#add-remove-buttons').on('click', function(){
    alert('btn clicked');
  })
  $('#add-remove-buttons').trigger('click');
})<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button id="add-remove-buttons">Click</button>