JavaScript
10
Вклад в тег
<head>
<script>
var metaTag=document.createElement('meta');
metaTag.name = "viewport";
if (screen.width <= 479) {
metaTag.content = "width=480, user-scalable=false"
window.addEventListener("orientationchange", function() {
viewport = document.querySelector("meta[name=viewport]");
if(window.orientation === 90 || window.orientation === -90){
viewport.setAttribute('content', 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=false');
} else{
viewport.setAttribute('content', 'width=480, user-scalable=false');
};
}, false);
} else{
metaTag.content = "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=false"
};
document.getElementsByTagName('head')[0].appendChild(metaTag);
</script>
</head>
// jQuery
$(".submenu ul li").each(({ target }) => {
if ($(target).hasClass("active")) {
$(target).closest(".submenu").addClass("vision");
}
});
// ES6 syntax
document.querySelectorAll(".submenu ul li").forEach(({ target }) => {
if (target.className.includes("active")) {
target.closest(".submenu").classList.add("vision");
}
});