Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Feb 01 00:27
    @bjorno43 banned @Ndoua
  • Jan 07 03:10
    @bjorno43 banned @doctor-sam
  • Aug 17 2019 09:32
    User @bjorno43 unbanned @linkin-park
  • Jun 20 2019 21:19
    @bjorno43 banned @shenerd140
  • Apr 25 2019 17:13
    @mstellaluna banned @cmal
  • Jan 08 2019 22:05
    @mstellaluna banned @dertiuss323
  • Nov 07 2018 04:42
    User @texas2010 unbanned @ows-ali
  • Nov 02 2018 16:25
    @texas2010 banned @ows-ali
  • Oct 12 2018 05:50
    @bjorno43 banned @NACH74
  • Oct 05 2018 23:02
    @mstellaluna banned @JomoPipi
  • Sep 16 2018 12:21
    @bjorno43 banned @yash-kedia
  • Sep 16 2018 12:16
    @bjorno43 banned @vnikifirov
  • Sep 05 2018 08:12
    User @bjorno43 unbanned @androuino
  • Sep 05 2018 07:38
    @bjorno43 banned @androuino
  • Aug 23 2018 16:57
    User @bjorno43 unbanned @rahuldkjain
  • Aug 23 2018 16:23
    @bjorno43 banned @rahuldkjain
  • Jul 29 2018 14:13
    User @bjorno43 unbanned @jkyereh
  • Jul 29 2018 01:00
    @bjorno43 banned @jkyereh
  • Jul 10 2018 22:09
    @bjorno43 banned @manafn
  • Jul 06 2018 15:20
    @texas2010 banned @imlegend19
:)
Christopher McCormack
@cmccormack
thanks
@danydin did you change it to onclick? worked for me
Dany Din
@danydin
ya still not working
<script>
  document.addEventListener('DOMContentLoader', function(){
    document.getElementById('getMessage').onclick=function(){};
  });
</script>
this? ^
@cmccormack
Aditya
@ezioda004
@danydin Its DOMContentLoaded not DOMContentLoader
Christopher McCormack
@cmccormack
@danydin that should have already been configured, did you change it?
Dany Din
@danydin
ahh fcl this shit thanks you too @cmccormack @ezioda004
BrianWilliams28
@BrianWilliams28
how can i set the content of my 3 list items here in pure JS?

let navEl = document.createElement("nav");
let brandEl = document.createElement("div");
let brandTag = document.createElement("a");
let navLinksEl = document.createElement("ul");
let liEls = document.createElement("li");
navLinksEl.className = "nav-links";
navLinksEl.appendChild(liEls);
navLinksEl.appendChild(liEls);
navLinksEl.appendChild(liEls);

brandTag.href="#";
brandEl.className = "brand";
let titleEl = document.createTextNode("Javascript Page");
document.body.appendChild(navEl).appendChild(brandEl).appendChild(brandTag).appendChild(titleEl);
navEl.appendChild(navLinksEl);
br3ntor
@br3ntor
for (let i = 0; i < 3; i++) {
  let liEls = document.createElement("li");
  liEls.textContent = i;
  navLinksEl.appendChild(liEls);
}
Something like this maybe?
Liam Wears
@lwears
@AJ-Brommy Thanks for checking. Sorry for the delay in responding. It was just me having tired eyes / brain!
Eric Weiss
@eweiss17
@BrianWilliams28 if you are used to using jquery, there is a jquery to base js converter
Fernando L. Estuesta
@champolot
Is there any one here could explain why I get an error on this code
Daniel Simeonov
@dbsimeonov
Send it and we will try to help you
Fernando L. Estuesta
@champolot
UI.prototype.showAlert=function(message,class name)
It says classname is not declared but it's value is never read
Eric Weiss
@eweiss17
can u give the relevant code snippets
Fernando L. Estuesta
@champolot
Sorry for the typo on my code. That's className
BrianWilliams28
@BrianWilliams28
@br3ntor yeah but I want each LI to have different content xD
Fernando L. Estuesta
@champolot

heres the full code

function Book(title, author, isbn) {
this.title = title;
this.author = author;
this.isbn = isbn;
}

function UI() {}

UI.prototype.addBookToList = function(book) {
const list = document.getElementById('book-list');
const row = document.createElement('tr');
row.innerHTML = <td>${book.title}</td> <td>${book.author}</td> <td>${book.isbn}</td> <td><a href="#" class="delete">X </a></td>;
list.appendChild(row);
};

UI.prototype.showAlert = function(message, className) {};

UI.prototype.clearFields = function() {
document.getElementById('title').value = '';
document.getElementById('author').value = '';
document.getElementById('isbn').value = '';
};

document.getElementById('book-form').addEventListener('submit', function(e) {
const title = document.getElementById('title').value,
author = document.getElementById('author').value,
isbn = document.getElementById('isbn').value;

const book = new Book(title, author, isbn);

const ui = new UI();

if (title === '' || author === '' || isbn === '') {
ui.showAlert('Please fill all', 'error');
} else {
ui.addBookToList(book);
ui.clearFields();
}

e.preventDefault();
});

xDDD
Daniel Simeonov
@dbsimeonov
What error gives you, className not defined? Did you try to register it and writing some output in the function instead being empty?
Im not expert with prototype functions but never seen that approach :D
Fernando L. Estuesta
@champolot
any thing that is inside the function
Markus Kiili
@Masd925
@champolot You have commas at the ends of lines there const title = document.getElementById('title').value,. Should they be semicolons?
Daniel Simeonov
@dbsimeonov
I think that was a way to assign multiple variables like he did ?
Markus Kiili
@Masd925
oh yes, you are right. Missed the const there.
Fernando L. Estuesta
@champolot
it was actually working
Ghost
@ghost~5a7ec891d73408ce4f8c87b2
I'm facing one problem in HTML, CSS
that I can't add Background Image to HTML file with /photos/xyz.jpg that need complete file url, like file:///C:/Users/Name%20Name%20Name/Desktop/Coursera%20Learning/Portfolio%20New%201/images/iPhone.jpg
why ?
please help me out
Eric Weiss
@eweiss17
are you developing locally?
Dany Din
@danydin
hey someone is here
Christopher McCormack
@cmccormack
@danydin who is it?
Dany Din
@danydin
when i use the stringify and the parse im confused a bit @cmccormack
Christopher McCormack
@cmccormack
@danydin what's your confusion?
Dany Din
@danydin
like when i make a call and i get the data
to manipualte it i need to parse it first
do i need to stringify it again afterwards?
hensn5250
@hensn5250
@danydin the data can be manipulated when in JSON form, so if it is in JSON form no need to Stringify it.

"A common use of JSON is to exchange data to/from a web server.

When receiving data from a web server, the data is always a string.

Parse the data with JSON.parse(), and the data becomes a JavaScript object."

Dany Din
@danydin
@hensn5250 thanks why i see sometimes variables without the var
hensn5250
@hensn5250
No prob.
In JavaScript undeclared variables are global by default.
"If you assign a value to a variable that has not been declared, it will automatically become a GLOBAL variable."
JavaScript Scope
Dany Din
@danydin
@hensn5250 you're amazing
hensn5250
@hensn5250
JSON is JavaScript Object Notation , its just a ** Stringified JS object --> ' { key: value}'