Jquery kodu JS yazma
Merhabalar arkadaslar jquery koduma normal javascript`ine yazmak istiyorum yeni basladim javascript
bu jquery kod
$(function() {
let openMenu = $('#open-menu-btn'),
responsiveMenu = $('#responsive-menu'),
logo = $('.header .logo'),
search = $('.header .search'),
menu = $('.header .menu'),
social = $('.header .social');
let responsiveMenuHTML = `
<a href="#" class="close-menu" id="close-menu-btn"><i class='fa fa-times'></i></a>
<div class='logo'>${logo.html()}</div>
<div class='search'>${search.html()}</div>
<div class='menu'>${menu.html()}</div>
<div class='social'>${social.html()}</div>
`;
responsiveMenu.html(responsiveMenuHTML);
let closeMenu = $('#close-menu-btn');
openMenu.on('click', e => {
responsiveMenu.addClass('active');
e.preventDefault();
});
closeMenu.on('click', e => {
responsiveMenu.removeClass('active');
e.prevenDefault();
})
});
bu`da benim yazdim js kod
let openMenu = document.querySelector("#open-menu-btn");
let responsiveMenu = document.querySelector("#responsive-menu");
const logo = document.querySelector(".logo");
const search = document.querySelector(".search");
const menu = document.querySelector(".menu");
const social = document.querySelector(".social");
function islem() {
let responsiveMenuHTML = `
<a href="#" class="close-menu" id="close-menu-btn"><i class='fa fa-times'></i></a>
<div class='logo'>${logo.innerHTML()}</div>
<div class='search'>${search.innerHTML()}</div>
<div class='menu'>${menu.innerHTML()}</div>
<div class='social'>${social.innerHTML()}</div>
`;
responsiveMenu.appendChild(innerHTML(responsiveMenuHTML));
let closeMenu = document.querySelector("#close-menu-btn");
openMenu.addEventListener("click", (e) => {
responsiveMenu.classList.add("active");
e.preventDefault();
});
closeMenu.addEventListener("click", (e) => {
responsiveMenu.classList.remove("active");
e.preventDefault();
});
}
islem();
Soru hatalı mı? 👎
Eğer sorunun kurallara aykırı olduğunu düşünüyorsanız lütfen bize bildirin!