Как добавить еще один id к скрипту jquery?
Есть у меня табы от bootstrap3, нашел скрипт который по ссылке сразу перенаправляет до открытых табов, но пришлось добавить еще один таб и по итогу на него именно это не работает совсем, как это решить? табы идентичные почти ID другие. Вот изначальный скрипт
$(document).ready(() => {
let url = location.href.replace(/\/$/, "");
if (location.hash) {
const hash = url.split("#");
$('#myTab a[href="#'+hash[1]+'"]').tab("show");
url = location.href.replace(/\/#/, "#");
history.replaceState(null, null, url);
}
$('a[data-toggle="tab"]').on("click", function() {
let newUrl;
const hash = $(this).attr("href");
if(hash == "#home") {
newUrl = url.split("#")[0];
} else {
newUrl = url.split("#")[0] + hash;
}
newUrl += "/";
history.replaceState(null, null, newUrl);
});
});
Пытался так
if (location.hash) {
const hash = url.split("#");
$('#myTab a[href="#'+hash[1]+'"]').tab("show");
$('#mynewTab a[href="#'+hash[1]+'"]').tab("show");
url = location.href.replace(/\/#/, "#");
history.replaceState(null, null, url);
}
или дублировал
if (location.hash) {
const hash = url.split("#");
$('#myTab a[href="#'+hash[1]+'"]').tab("show");
url = location.href.replace(/\/#/, "#");
history.replaceState(null, null, url);
}
if (location.hash) {
const hash = url.split("#");
$('#mynewTab a[href="#'+hash[1]+'"]').tab("show");
url = location.href.replace(/\/#/, "#");
history.replaceState(null, null, url);
}