jquery - Is there way to make two HTML ID's link to one javascript function? -
i have 2 tables need have different ids or not work. i'm using 3rd party data table code uses id differentiate between different tables in browser.
<table id="promo" class="display"> <table id="official" class="display">
but need them both link same script function. can see below, have 1 #promo , 1 #official both using exact same code:
$(document).ready(function() { $('#promo').datatable( { // ton of stuff here } ); $('#official').datatable( { // ton of stuff here } );
is there way make both tables link same code in script?
is there way make both tables link same code in script?
yes:
$('#promo, #official').datatable( { // ton of stuff here });
this uses css group selector, can use other selector matches both elements. based on question, instance, .display
(a class selector) (provided doesn't match other elements haven't shown):
$('.display').datatable( { // ton of stuff here });
Comments
Post a Comment