$('.sss').on('click', function(e) {
e.preventDefault();
var currentName = $(this).find('.product__item-name').text() // Если .product__item-name находится внутри кликнутого .sss
console.log(currentName);
});
$('.dop-info').hide()
$('.btn-collapse.transition.collapsed').on('click', function (){
$(this).find(".col-xs-6.col-sm-12.dop-info").show() // или toggle(), вместо show(), чтоб показать\скрыть
});
var myAudio = myAudioHoverBlock[i].querySelector('audio')
$('a[href^="#"]')
<a>
, href которых начинается с #$('a[href*=".html#"]')
try {
const deadlineInput3 = document.querySelector('[name="quiz_deadline"]')
let deadline3 = deadlineInput3.getAttribute('value')
// Если это Сафари
if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
deadline3 = deadline3.replace(/-/g, '/').replace(/\./g, '/')
}
timer('#quizeTimer', deadline3)
console.log(deadline3)
} catch (error) {
console.log('timer catch')
alert(error)
}
</body>
, в данном случае. <div class="container">
<ul id="list">
<li class="element">
</li>
<li class="element">
</li>
<li class="element">
</li>
<li class="element"> <!-- тут класс с опечаткой был -->
</li>
</ul>
</div>
let el = document.querySelectorAll('.element'),
container = document.querySelector('#list'); // был выбран класс .container, а клонируемый элемент <li> должен быть в <ul>
let elClone = el[0].cloneNode();
container.appendChild(elClone); // была опечатка в слове appendChild
let list = document.querySelector('#list'),
container = document.querySelector('.container');
container.appendChild(list.cloneNode(true));
if(window.location.search.indexOf('test=') != -1){
// условие сработает, если есть "test=" в "www.site.com/?test=lalala"
}
var getParams;
// Если get-параметров много
if(window.location.search.indexOf('&') != -1){
getParams = window.location.search.split('&').map(function(item){
var currentValue = item.split('=');
return {[currentValue[0]]: currentValue[1]}
});
// если один
} else {
var currentValue = window.location.search.replace(/\?/, '').split('=');
getParams = {[currentValue[0]]: currentValue[1]};
}
console.log(getParams);
window.addEventListener('load', function(){
// ваш код
})
document.getElementById('primer2').addEventListener('click', showtext)
<body>
(эти типо расположит весь JS в самом конце содержимого body, без обёртывания в анонимную функцию) <select class="form-control" id="status-scan">
<option value="0">Укажите статус</option>
<option value="1">Выполнено</option>
</select>
$('#status-scan').on('change', function(){
var isDone = $(this).val() == 1;
$('.coolTable tr[data-scan]').each(function(idx, elm){
$(elm).toggle($(elm).attr('data-scan').length > 0 || !isDone);
});
})
[
{
"id": 250,
"name": "Small Batch: Rye IPA",
"tagline": "Rye India Pale Ale.",
"first_brewed": "2016",
"description": "A 7.2% rye IPA loaded with grapefruit notes, pithy citrus, and huge resinous bitterness, with rye character. The Centennial and Columbus flavours are amplified by the spicy, dry rye.",
"image_url": "https://images.punkapi.com/v2/keg.png",
"abv": 7.2,
"ibu": 100,
"target_fg": 1010,
"target_og": 1065,
"ebc": 8,
"srm": 16,
"ph": 4.4,
"attenuation_level": 84,
"volume":
{
"value": 20,
"unit": "litres"
},
"boil_volume":
{
"value": 25,
"unit": "litres"
},
"method":
{
"mash_temp": [
{
"temp":
{
"value": 60,
"unit": "celsius"
},
"duration": 30
},
{
"temp":
{
"value": 65,
"unit": "celsius"
},
"duration": 20
},
{
"temp":
{
"value": 72,
"unit": "celsius"
},
"duration": 15
},
{
"temp":
{
"value": 78,
"unit": "celsius"
},
"duration": 10
}],
"fermentation":
{
"temp":
{
"value": 21,
"unit": "celsius"
}
},
"twist": null
},
"ingredients":
{
"malt": [
{
"name": "Maris Otter",
"amount":
{
"value": 4,
"unit": "kilograms"
}
},
{
"name": "Rye",
"amount":
{
"value": 0.8,
"unit": "kilograms"
}
}],
"hops": [
{
"name": "Centennial",
"amount":
{
"value": 40,
"unit": "grams"
},
"add": "60",
"attribute": "Bitter"
},
{
"name": "Centennial",
"amount":
{
"value": 15,
"unit": "grams"
},
"add": "15",
"attribute": "Bitter"
},
{
"name": "Columbus",
"amount":
{
"value": 15,
"unit": "grams"
},
"add": "15",
"attribute": "Flavour"
},
{
"name": "Centennial",
"amount":
{
"value": 50,
"unit": "grams"
},
"add": "Whirlpool",
"attribute": "Aroma"
},
{
"name": "Columbus",
"amount":
{
"value": 25,
"unit": "grams"
},
"add": "Whirlpool",
"attribute": "Aroma"
},
{
"name": "Columbus",
"amount":
{
"value": 10,
"unit": "grams"
},
"add": "Dry Hop",
"attribute": "Aroma"
},
{
"name": "Citra",
"amount":
{
"value": 10,
"unit": "grams"
},
"add": "Dry Hop",
"attribute": "Aroma"
}],
"yeast": "Wyeast 1272 - American Ale II™"
},
"food_pairing": ["Salmon Fishcakes with Rocket Salad", "Baked Goat's Cheese", "Classic Victoria Sponge"],
"brewers_tips": "Be prepared for a long sparge as the rye content is really high.",
"contributed_by": "John Jenkman <johnjenkman>"
}]
<body>
<script src="index.js"></script>
</body>
const xml = new XMLHttpRequest();
xml.open('GET', 'https://api.punkapi.com/v2/beers/random', true);
xml.send();
xml.onload = () => {
const json = JSON.parse(xml.responseText);
let allItems = '';
json.forEach(item => {
allItems += '<div class="card" style="width: 18rem;"> <img class="card-img-top beer-image" src="' + item.image_url + '" alt="Card image cap" /> <div class="card-body"> <h5 id="nameBeer" class="card-title beer-name">' + item.name + '</h5> <p class="card-text beer-description">' + item.description + '</p> <a href="#" class="btn btn-primary">Go somewhere</a> </div> </div>';
});
document.body.innerHTML = allItems;
};
const all = {
"global": [
{
"id": "1",
"width": "50",
"height": "150"
},
{
"id": "2",
"width": "150",
"height": "350"
},
{
"id": "3",
"width": "750",
"height": "850"
}
]
};
for(item of all.global){
let elm = document.querySelector('.layer' + item.id);
elm.style.width = item.width + 'px';
elm.style.height = item.height + 'px';
}
$.ajax({
method: "POST",
contentType: false,
processData: false,
data: new FormData($(".divAddObject:visible form")[0]),
url: "handlers/add_object.php",
success: function (data){}
});
var formData = $(this).closest('form').serialize();
$.ajax({
method: "POST",
contentType: false,
processData: false,
data: formData,
url: "handlers/add_object.php",
success: function (data){}
});