Цена завернута в див price prc-new
$('[name="variant"] option:checked').data('price')
$('.price.prc-new span').text()
$('input').on('input', function() {
$(this).val((i, v) => Math.max(this.min, Math.min(this.max, v)));
});
document.querySelector('input').addEventListener('input', ({ target: t }) => {
t.value = Math.max(t.min, Math.min(t.max, t.value));
});
$('.price').text((i, text) => {
const [ price, currency ] = text.split(' ');
return `${(+price).toLocaleString()} ${currency}`;
});
const buttonSelector = '.button';
const blockSelector = '.div';
const activeClass = 'red';
function toggleBlock(blocks, buttons, button) {
const index = Array.prototype.indexOf.call(buttons, button);
blocks.forEach((n, i) => {
n.classList[i === index ? 'toggle' : 'remove'](activeClass);
});
}
// обработчик клика делегированный, назначается один раз
document.addEventListener('click', e => {
const button = e.target.closest(buttonSelector);
if (button) {
const blocks = document.querySelectorAll(blockSelector);
const buttons = document.querySelectorAll(buttonSelector);
toggleBlock(blocks, buttons, button);
}
});
// или, назначаем обработчик клика каждой кнопке индивидуально
const buttons = document.querySelectorAll(buttonSelector);
const blocks = document.querySelectorAll(blockSelector);
const onClick = e => toggleBlock(blocks, buttons, e.currentTarget);
buttons.forEach(n => n.addEventListener('click', onClick));
const data = $('.price')
.filter((i, n) => +n.value)
.closest('tr')
.find('input[type="hidden"]')
.get()
.map(n => n.value);
const data = Array
.from(document.querySelectorAll('.price'))
.filter(n => +n.value)
.map(n => n.closest('tr').querySelector('input[type="hidden"]').value);
.xxx {
background: silver;
display: inline-flex;
justify-content: center;
align-items: center;
font-size: 24px;
padding: 0.3em 0.6em;
position: relative;
}
.xxx::before {
content: "";
width: 1em;
height: 1em;
left: -0.2em;
top: -0.2em;
background: orange;
position: absolute;
z-index: -1;
}
<span class="prev" data-step="-1">Prev</span>
<span class="next" data-step="+1">Next</span>
eq
позволяет указывать отрицательные индексы, которые используются для отсчёта позиции элемента начиная с конца; в случае чистого js надо будет добавить к сумме количество элементов, чтобы потенциальное отрицательное значение стало положительным, и при этом не изменился остаток от деления.const itemSelector = 'li';
const buttonSelector = '[data-step]';
const activeClass = 'active';
$(buttonSelector).click(function() {
const { step } = this.dataset;
const $items = $(itemSelector);
const $active = $items.filter(`.${activeClass}`);
$active.removeClass(activeClass);
$items.eq(($active.index() + +step) % $items.length).addClass(activeClass);
});
// или
const items = document.querySelectorAll(itemSelector);
let index = 0;
document.querySelectorAll(buttonSelector).forEach(n => {
n.addEventListener('click', onClick);
});
function onClick({ currentTarget: { dataset: { step } } }) {
items[index].classList.remove(activeClass);
index = (index + items.length + +step) % items.length;
items[index].classList.add(activeClass);
}
SELECT * FROM `table` WHERE `id` >= 76 AND `id` <= 936 AND`date` >= '2018-01-10' AND `date` <= '2018-02-01'
#или
SELECT * FROM `table` WHERE `date` BETWEEN '2018-09-10' AND '2018-11-10'
#или
SELECT * FROM `table` WHERE `date` IN ( '2018-09-10', '2018-11-10', '2018-10-10' )
SELECT DATE_FORMAT(`date`,"%d.%m.%Y") AS `date` FROM `table` WHERE id=1
<select id = 'shop'>
<option value = '0'>Фуршет</option>
<option value = '1'>Ашан</option>
<option value = '2'>Простор</option>
</select>
<select id = 'cathegory'></select>
$( 'select#shop' ).on( 'change', function() {
$.post( 'select_cathegory.php', {
data: { parent_id: this.value }, // поразумеваются, что значения для селекта #shop соответствуют parent_id в БД
success: function( response ) {
$( 'select#cathegory' ).html( response )
}
} )
} )
$result = mysql_query( 'SELECT * FROM objects WHERE parent_id = ' . $_POST[ 'parent_id' ] );
while ( $row = mysql_fetch_array( $result, MYSQL_ASSOC ) ) {
echo ( '<option value = '. $row[ 'cathegory_id' ].'>'. $row[ 'cathegory_name' ] .'</option>' );
}