Responsiv website error with js and jquery





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















Hello i am qute new to js and jquery and i am making a responsive site but its not working. The point is to have a responsiv site and when it goes down to 599px it should delete the "nav" and then put 2 divs in one to the left and another to the right. But obviously the js/jquery isnt. So i would be grateful if anyone has the energy see what i did wrong and tech me how to do it right. Thanks I have this piece of code:






function myFunction(x) {
if (x.matches) { // If media query matches
$( '.nav' ).remove();
$('#bakgrund').before('<div class="left> <ul class="nav">
<li><a href="index.html">Hem</a></li>
<li><a href="#produkter">Produkter</a></li>
<li><a href="#nyaprodukter">Nya Produkter</a></li>
</ul></div>');
$('#bakgrund').before('<div class="right"> <ul class="nav">
<li><a href="#nyheter">Nyheter</a></li>
<li><a href="#kontakta_info">Kontakta oss/Info</a></li>
<li><a href="#hjälp">Hjälp</a></li>
</ul></div>');
} else {
$( ".left" ).remove();
$( ".right" ).remove();
}
}

var x = window.matchMedia("(max-width: 599px)")
myFunction(x) // Call listener function at run time
x.addListener(myFunction) // Attach listener function on state changes

@charset "utf8";

.nav {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}
li {
width: auto;
margin-right: 8px;
font-size: 34px;
float: left;
}
.nav li a {
display:block;
color: white;
padding: 14px 16px;
text-decoration: none;
}
.nav li a:hover {background-color: #111;
}


.left {
float: left;
width: 50%;
}
.right {
float: right;
width: 50%;
}

body {
height: 100%;
}
img {
max-width:100%;
height:auto;
}

<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<link rel="stylesheet" type="text/css" href="assets/css/reset.css">
<link rel="stylesheet" type="text/css" href="assets/css/main.css">
<link rel="stylesheet" type="text/css" href="assets/css/menu.css">
<link rel="stylesheet" type="text/css" href="assets/css/responsiv.css">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ahome</title>
</head>
<body>

<!-- <div class="left">
<ul class="nav">
<li><a href="index.html">Hem</a></li>
<li><a href="#produkter">Produkter</a></li>
<li><a href="#nyaprodukter">Nya Produkter</a></li>
</ul>
</div>

<div class="right">
<ul class="nav">
<li><a href="#nyheter">Nyheter</a></li>
<li><a href="#kontakta_info">Kontakta oss/Info</a></li>
<li><a href="#hjälp">Hjälp</a></li>
</ul>
</div>-->


<ul id="ett" class="nav">
<li><a href="index.html">Hem</a></li>
<li><a href="#produkter">Produkter</a></li>
<li><a href="#nyaprodukter">Nya Produkter</a></li>
<li><a href="#nyheter">Nyheter</a></li>
<li><a href="#kontakta_info">Kontakta oss/Info</a></li>
<li><a href="#hjälp">Hjälp</a></li>
</ul>


<img id="bakgrund" src="assets/pictures/homefinal.jpg">



<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script src="assets/js/myscript.js"></script>
</body>
</html>












share|improve this question


















  • 2





    Please read how to create multiline string stackoverflow.com/questions/805107/…

    – ponury-kostek
    Nov 16 '18 at 13:37


















0















Hello i am qute new to js and jquery and i am making a responsive site but its not working. The point is to have a responsiv site and when it goes down to 599px it should delete the "nav" and then put 2 divs in one to the left and another to the right. But obviously the js/jquery isnt. So i would be grateful if anyone has the energy see what i did wrong and tech me how to do it right. Thanks I have this piece of code:






function myFunction(x) {
if (x.matches) { // If media query matches
$( '.nav' ).remove();
$('#bakgrund').before('<div class="left> <ul class="nav">
<li><a href="index.html">Hem</a></li>
<li><a href="#produkter">Produkter</a></li>
<li><a href="#nyaprodukter">Nya Produkter</a></li>
</ul></div>');
$('#bakgrund').before('<div class="right"> <ul class="nav">
<li><a href="#nyheter">Nyheter</a></li>
<li><a href="#kontakta_info">Kontakta oss/Info</a></li>
<li><a href="#hjälp">Hjälp</a></li>
</ul></div>');
} else {
$( ".left" ).remove();
$( ".right" ).remove();
}
}

var x = window.matchMedia("(max-width: 599px)")
myFunction(x) // Call listener function at run time
x.addListener(myFunction) // Attach listener function on state changes

@charset "utf8";

.nav {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}
li {
width: auto;
margin-right: 8px;
font-size: 34px;
float: left;
}
.nav li a {
display:block;
color: white;
padding: 14px 16px;
text-decoration: none;
}
.nav li a:hover {background-color: #111;
}


.left {
float: left;
width: 50%;
}
.right {
float: right;
width: 50%;
}

body {
height: 100%;
}
img {
max-width:100%;
height:auto;
}

<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<link rel="stylesheet" type="text/css" href="assets/css/reset.css">
<link rel="stylesheet" type="text/css" href="assets/css/main.css">
<link rel="stylesheet" type="text/css" href="assets/css/menu.css">
<link rel="stylesheet" type="text/css" href="assets/css/responsiv.css">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ahome</title>
</head>
<body>

<!-- <div class="left">
<ul class="nav">
<li><a href="index.html">Hem</a></li>
<li><a href="#produkter">Produkter</a></li>
<li><a href="#nyaprodukter">Nya Produkter</a></li>
</ul>
</div>

<div class="right">
<ul class="nav">
<li><a href="#nyheter">Nyheter</a></li>
<li><a href="#kontakta_info">Kontakta oss/Info</a></li>
<li><a href="#hjälp">Hjälp</a></li>
</ul>
</div>-->


<ul id="ett" class="nav">
<li><a href="index.html">Hem</a></li>
<li><a href="#produkter">Produkter</a></li>
<li><a href="#nyaprodukter">Nya Produkter</a></li>
<li><a href="#nyheter">Nyheter</a></li>
<li><a href="#kontakta_info">Kontakta oss/Info</a></li>
<li><a href="#hjälp">Hjälp</a></li>
</ul>


<img id="bakgrund" src="assets/pictures/homefinal.jpg">



<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script src="assets/js/myscript.js"></script>
</body>
</html>












share|improve this question


















  • 2





    Please read how to create multiline string stackoverflow.com/questions/805107/…

    – ponury-kostek
    Nov 16 '18 at 13:37














0












0








0








Hello i am qute new to js and jquery and i am making a responsive site but its not working. The point is to have a responsiv site and when it goes down to 599px it should delete the "nav" and then put 2 divs in one to the left and another to the right. But obviously the js/jquery isnt. So i would be grateful if anyone has the energy see what i did wrong and tech me how to do it right. Thanks I have this piece of code:






function myFunction(x) {
if (x.matches) { // If media query matches
$( '.nav' ).remove();
$('#bakgrund').before('<div class="left> <ul class="nav">
<li><a href="index.html">Hem</a></li>
<li><a href="#produkter">Produkter</a></li>
<li><a href="#nyaprodukter">Nya Produkter</a></li>
</ul></div>');
$('#bakgrund').before('<div class="right"> <ul class="nav">
<li><a href="#nyheter">Nyheter</a></li>
<li><a href="#kontakta_info">Kontakta oss/Info</a></li>
<li><a href="#hjälp">Hjälp</a></li>
</ul></div>');
} else {
$( ".left" ).remove();
$( ".right" ).remove();
}
}

var x = window.matchMedia("(max-width: 599px)")
myFunction(x) // Call listener function at run time
x.addListener(myFunction) // Attach listener function on state changes

@charset "utf8";

.nav {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}
li {
width: auto;
margin-right: 8px;
font-size: 34px;
float: left;
}
.nav li a {
display:block;
color: white;
padding: 14px 16px;
text-decoration: none;
}
.nav li a:hover {background-color: #111;
}


.left {
float: left;
width: 50%;
}
.right {
float: right;
width: 50%;
}

body {
height: 100%;
}
img {
max-width:100%;
height:auto;
}

<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<link rel="stylesheet" type="text/css" href="assets/css/reset.css">
<link rel="stylesheet" type="text/css" href="assets/css/main.css">
<link rel="stylesheet" type="text/css" href="assets/css/menu.css">
<link rel="stylesheet" type="text/css" href="assets/css/responsiv.css">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ahome</title>
</head>
<body>

<!-- <div class="left">
<ul class="nav">
<li><a href="index.html">Hem</a></li>
<li><a href="#produkter">Produkter</a></li>
<li><a href="#nyaprodukter">Nya Produkter</a></li>
</ul>
</div>

<div class="right">
<ul class="nav">
<li><a href="#nyheter">Nyheter</a></li>
<li><a href="#kontakta_info">Kontakta oss/Info</a></li>
<li><a href="#hjälp">Hjälp</a></li>
</ul>
</div>-->


<ul id="ett" class="nav">
<li><a href="index.html">Hem</a></li>
<li><a href="#produkter">Produkter</a></li>
<li><a href="#nyaprodukter">Nya Produkter</a></li>
<li><a href="#nyheter">Nyheter</a></li>
<li><a href="#kontakta_info">Kontakta oss/Info</a></li>
<li><a href="#hjälp">Hjälp</a></li>
</ul>


<img id="bakgrund" src="assets/pictures/homefinal.jpg">



<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script src="assets/js/myscript.js"></script>
</body>
</html>












share|improve this question














Hello i am qute new to js and jquery and i am making a responsive site but its not working. The point is to have a responsiv site and when it goes down to 599px it should delete the "nav" and then put 2 divs in one to the left and another to the right. But obviously the js/jquery isnt. So i would be grateful if anyone has the energy see what i did wrong and tech me how to do it right. Thanks I have this piece of code:






function myFunction(x) {
if (x.matches) { // If media query matches
$( '.nav' ).remove();
$('#bakgrund').before('<div class="left> <ul class="nav">
<li><a href="index.html">Hem</a></li>
<li><a href="#produkter">Produkter</a></li>
<li><a href="#nyaprodukter">Nya Produkter</a></li>
</ul></div>');
$('#bakgrund').before('<div class="right"> <ul class="nav">
<li><a href="#nyheter">Nyheter</a></li>
<li><a href="#kontakta_info">Kontakta oss/Info</a></li>
<li><a href="#hjälp">Hjälp</a></li>
</ul></div>');
} else {
$( ".left" ).remove();
$( ".right" ).remove();
}
}

var x = window.matchMedia("(max-width: 599px)")
myFunction(x) // Call listener function at run time
x.addListener(myFunction) // Attach listener function on state changes

@charset "utf8";

.nav {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}
li {
width: auto;
margin-right: 8px;
font-size: 34px;
float: left;
}
.nav li a {
display:block;
color: white;
padding: 14px 16px;
text-decoration: none;
}
.nav li a:hover {background-color: #111;
}


.left {
float: left;
width: 50%;
}
.right {
float: right;
width: 50%;
}

body {
height: 100%;
}
img {
max-width:100%;
height:auto;
}

<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<link rel="stylesheet" type="text/css" href="assets/css/reset.css">
<link rel="stylesheet" type="text/css" href="assets/css/main.css">
<link rel="stylesheet" type="text/css" href="assets/css/menu.css">
<link rel="stylesheet" type="text/css" href="assets/css/responsiv.css">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ahome</title>
</head>
<body>

<!-- <div class="left">
<ul class="nav">
<li><a href="index.html">Hem</a></li>
<li><a href="#produkter">Produkter</a></li>
<li><a href="#nyaprodukter">Nya Produkter</a></li>
</ul>
</div>

<div class="right">
<ul class="nav">
<li><a href="#nyheter">Nyheter</a></li>
<li><a href="#kontakta_info">Kontakta oss/Info</a></li>
<li><a href="#hjälp">Hjälp</a></li>
</ul>
</div>-->


<ul id="ett" class="nav">
<li><a href="index.html">Hem</a></li>
<li><a href="#produkter">Produkter</a></li>
<li><a href="#nyaprodukter">Nya Produkter</a></li>
<li><a href="#nyheter">Nyheter</a></li>
<li><a href="#kontakta_info">Kontakta oss/Info</a></li>
<li><a href="#hjälp">Hjälp</a></li>
</ul>


<img id="bakgrund" src="assets/pictures/homefinal.jpg">



<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script src="assets/js/myscript.js"></script>
</body>
</html>








function myFunction(x) {
if (x.matches) { // If media query matches
$( '.nav' ).remove();
$('#bakgrund').before('<div class="left> <ul class="nav">
<li><a href="index.html">Hem</a></li>
<li><a href="#produkter">Produkter</a></li>
<li><a href="#nyaprodukter">Nya Produkter</a></li>
</ul></div>');
$('#bakgrund').before('<div class="right"> <ul class="nav">
<li><a href="#nyheter">Nyheter</a></li>
<li><a href="#kontakta_info">Kontakta oss/Info</a></li>
<li><a href="#hjälp">Hjälp</a></li>
</ul></div>');
} else {
$( ".left" ).remove();
$( ".right" ).remove();
}
}

var x = window.matchMedia("(max-width: 599px)")
myFunction(x) // Call listener function at run time
x.addListener(myFunction) // Attach listener function on state changes

@charset "utf8";

.nav {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}
li {
width: auto;
margin-right: 8px;
font-size: 34px;
float: left;
}
.nav li a {
display:block;
color: white;
padding: 14px 16px;
text-decoration: none;
}
.nav li a:hover {background-color: #111;
}


.left {
float: left;
width: 50%;
}
.right {
float: right;
width: 50%;
}

body {
height: 100%;
}
img {
max-width:100%;
height:auto;
}

<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<link rel="stylesheet" type="text/css" href="assets/css/reset.css">
<link rel="stylesheet" type="text/css" href="assets/css/main.css">
<link rel="stylesheet" type="text/css" href="assets/css/menu.css">
<link rel="stylesheet" type="text/css" href="assets/css/responsiv.css">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ahome</title>
</head>
<body>

<!-- <div class="left">
<ul class="nav">
<li><a href="index.html">Hem</a></li>
<li><a href="#produkter">Produkter</a></li>
<li><a href="#nyaprodukter">Nya Produkter</a></li>
</ul>
</div>

<div class="right">
<ul class="nav">
<li><a href="#nyheter">Nyheter</a></li>
<li><a href="#kontakta_info">Kontakta oss/Info</a></li>
<li><a href="#hjälp">Hjälp</a></li>
</ul>
</div>-->


<ul id="ett" class="nav">
<li><a href="index.html">Hem</a></li>
<li><a href="#produkter">Produkter</a></li>
<li><a href="#nyaprodukter">Nya Produkter</a></li>
<li><a href="#nyheter">Nyheter</a></li>
<li><a href="#kontakta_info">Kontakta oss/Info</a></li>
<li><a href="#hjälp">Hjälp</a></li>
</ul>


<img id="bakgrund" src="assets/pictures/homefinal.jpg">



<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script src="assets/js/myscript.js"></script>
</body>
</html>





function myFunction(x) {
if (x.matches) { // If media query matches
$( '.nav' ).remove();
$('#bakgrund').before('<div class="left> <ul class="nav">
<li><a href="index.html">Hem</a></li>
<li><a href="#produkter">Produkter</a></li>
<li><a href="#nyaprodukter">Nya Produkter</a></li>
</ul></div>');
$('#bakgrund').before('<div class="right"> <ul class="nav">
<li><a href="#nyheter">Nyheter</a></li>
<li><a href="#kontakta_info">Kontakta oss/Info</a></li>
<li><a href="#hjälp">Hjälp</a></li>
</ul></div>');
} else {
$( ".left" ).remove();
$( ".right" ).remove();
}
}

var x = window.matchMedia("(max-width: 599px)")
myFunction(x) // Call listener function at run time
x.addListener(myFunction) // Attach listener function on state changes

@charset "utf8";

.nav {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}
li {
width: auto;
margin-right: 8px;
font-size: 34px;
float: left;
}
.nav li a {
display:block;
color: white;
padding: 14px 16px;
text-decoration: none;
}
.nav li a:hover {background-color: #111;
}


.left {
float: left;
width: 50%;
}
.right {
float: right;
width: 50%;
}

body {
height: 100%;
}
img {
max-width:100%;
height:auto;
}

<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<link rel="stylesheet" type="text/css" href="assets/css/reset.css">
<link rel="stylesheet" type="text/css" href="assets/css/main.css">
<link rel="stylesheet" type="text/css" href="assets/css/menu.css">
<link rel="stylesheet" type="text/css" href="assets/css/responsiv.css">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ahome</title>
</head>
<body>

<!-- <div class="left">
<ul class="nav">
<li><a href="index.html">Hem</a></li>
<li><a href="#produkter">Produkter</a></li>
<li><a href="#nyaprodukter">Nya Produkter</a></li>
</ul>
</div>

<div class="right">
<ul class="nav">
<li><a href="#nyheter">Nyheter</a></li>
<li><a href="#kontakta_info">Kontakta oss/Info</a></li>
<li><a href="#hjälp">Hjälp</a></li>
</ul>
</div>-->


<ul id="ett" class="nav">
<li><a href="index.html">Hem</a></li>
<li><a href="#produkter">Produkter</a></li>
<li><a href="#nyaprodukter">Nya Produkter</a></li>
<li><a href="#nyheter">Nyheter</a></li>
<li><a href="#kontakta_info">Kontakta oss/Info</a></li>
<li><a href="#hjälp">Hjälp</a></li>
</ul>


<img id="bakgrund" src="assets/pictures/homefinal.jpg">



<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script src="assets/js/myscript.js"></script>
</body>
</html>






javascript jquery html css






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 16 '18 at 13:32









NysseNysse

61




61








  • 2





    Please read how to create multiline string stackoverflow.com/questions/805107/…

    – ponury-kostek
    Nov 16 '18 at 13:37














  • 2





    Please read how to create multiline string stackoverflow.com/questions/805107/…

    – ponury-kostek
    Nov 16 '18 at 13:37








2




2





Please read how to create multiline string stackoverflow.com/questions/805107/…

– ponury-kostek
Nov 16 '18 at 13:37





Please read how to create multiline string stackoverflow.com/questions/805107/…

– ponury-kostek
Nov 16 '18 at 13:37












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53338895%2fresponsiv-website-error-with-js-and-jquery%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53338895%2fresponsiv-website-error-with-js-and-jquery%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Bressuire

Vorschmack

Quarantine