<a id="phone" href=""><a/>
document.addEventListener('DOMContentLoaded', function() {
var link = document.getElementById('phone');
var a = '+7(123) 123-45-67';
var b = '+8(321) 123-45-67';
link.innerText = b;
link.setAttribute('href', 'tel:' + b);
setInterval(function() {
link.innerText = link.innerText === b ? a : b;
link.setAttribute('href', 'tel:' + link.innerText);
}, 1000);
});
const filterBox = document.querySelectorAll('.goods-card');
document.querySelector('nav').addEventListener('click', (event) => {
if (event.target.tagName !== 'LI') return false;
let filterClass = event.target.dataset['f'];
filterBox.forEach ( elem => {
elem.classList.toggle('hide');
});
});
function aMob() {
$('select option[value=2]').prop('selected', true).trigger('change');
}
setTimeout(aMob, 0.3);
<button onclick="openModal(headline, price)">Открыть модальное окно</button>
function openModal(headline, price) {
var modal = $('#myModal');
// нужно добавить уникальный класс к h3 и .price
$(modal).find('.h3-modal__title').text(headline);
$(modal).find('.modal__price').text(price);
$(modal).modal('show')
}
function declOfNum(number, titles) {
cases = [2, 0, 1, 1, 1, 2];
return number+" "+titles[ (number%100>4 && number%100<20)? 2 : cases[(number%10<5)?number%10:5] ];
}
var date = declOfNum(new Date().getFullYear() - 2005, ['год', 'года', 'лет'])
var el = document.getElementById("demo")
el.innerText = date
<link media="only screen and (max-device-width: 600px)" href="mobile.css" type="text/css" rel="stylesheet" />
import { $, jQuery } from 'jquery';
window.$ = $;
window.jQuery = jQuery;
<script>
, то:<script src="../jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="../script.js"></script>
Подключать скрипты лучше в конец <body>
, перед закрытием тега
Хорошей практикой считается вызов jQuery функций только после того, как документ был полностью загружен:
$(document).ready(function(){
// тут код
})
"InAppPurchase[js]: product test has a transaction in progress: 1000000628239595"
this.iap.when(MONEYCOMBO_KEY).approved((product: IAPProduct) => {
product.finish()
this.getMoney()
})