<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href="style.css" id="styles">
</head>
<body>
<button class="change style">Сменить стили</button>
<script>
const link = document.querySelector('#styles');
const button = document.querySelector('.change');
button.onclick = ({ target }) => {
if (target.classList.contains('style')) {
target.classList.remove('style');
link.href = 'blind.css';
}
console.log(link.href)
}
</script>
</body>
</html>
<?php
$book = json_decode(file_get_contents('http://adventsent.pp.ua/rst.json'));
$arr = [];
foreach ($book->Books as $item) {
foreach ($item->Chapters as $val) {
foreach ($val->Verses as $v) {
$arr[] = $v;
}
}
}
$key = array_rand($arr);
var_dump($arr[$key]->Text);
const search = window.location.search;
const result = search.slice(search.indexOf('?') + 1).split('&').reduce((params, hash) => {
let [key, val] = hash.split('=')
return Object.assign(params, {[key]: decodeURIComponent(val)})
}, {})
console.log(result)
let data = {
id: 3,
method: 'fetch'
}
fetch("http://localhost:8080/test", {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: JSON.stringify(data)
});
//get запрос
$.get('file.php', {value: 'передаем параметр'}, data => {
if (data == 0) {
//если в ответе 0
} else if (data == 1) {
//если в ответе 1
}
})
//post
$.post('index.php', {key: value}, data => {
if (!data) {
//если в ответе 0
} else
//если в ответе 1
}
})