jagatuba
  • jagatuba
In JavaScript, is there a way to make content appear on the next line in a list without creating a new list item?
Computer Science
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
jamiebookeater
  • jamiebookeater
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
jagatuba
  • jagatuba
For more information I have two variables. title and description. I have a list and I want each title and description to be one list item, but I want the description to appear on the next line. \n does not seem to work.
amistre64
  • amistre64
if you mock up a little html it would be easier to see what you are trying to explain :)
anonymous
  • anonymous
\n doesn't work here but try t use
  • tag in the html page and when you press or hover on that item let it display the description. try similar to this document.getElementById("demo").innerHTML=Date();
  • Looking for something else?

    Not the answer you are looking for? Search for more explanations.

    More answers

    mattfeury
    • mattfeury
    You're probably going to want to put some more html markup in your list-item. e.g.:
  • title
    description
  • depending on your doctype and the like, it may not be 'proper' form to put block level elements (
    ) inside an inline element (
  • ), so you can make the
    s and use css to display them as block level, ie: li span { display: block; }
  • jagatuba
    • jagatuba
    Okay, still can't get ti to work. Here is the entire function: function listEvents(feedRoot) { var entries = feedRoot.feed.getEntries(); var eventDiv = document.getElementById('eventsLoaded'); if (eventDiv.childNodes.length > 0) { eventDiv.removeChild(eventDiv.childNodes[0]); } /* create a new unordered list */ var ul = document.createElement('ul'); /* set the calendarTitle div with the name of the calendar */ document.getElementById('calendarTitle').innerHTML = "Calendar: " + feedRoot.feed.title.$t; /* loop through each event in the feed */ var len = entries.length; for (var i = 0; i < len; i++) { var entry = entries[i]; var title = entry.getTitle().getText(); var content = entry.getContent().getText(); var startDateTime = null; var startJSDate = null; var times = entry.getTimes(); if (times.length > 0) { startDateTime = times[0].getStartTime(); startJSDate = startDateTime.getDate(); } var entryLinkHref = null; var todaysDate = new Date(); if (entry.getHtmlLink() != null) { if (startJSDate.getMonth() +1 == todaysDate.getMonth() + 1 && startJSDate.getDate() == todaysDate.getDate() + 1){ entryLinkHref = entry.getHtmlLink().getHref(); } } var dateString = (startJSDate.getMonth() + 1) + "/" + startJSDate.getDate() + " - "; if (!startDateTime.isDateOnly()) { if (startJSDate.getHours() > 12) { dateString += " " + startJSDate.getHours() - 12 + ":" + padNumber(startJSDate.getMinutes()); }else { dateString += " " + startJSDate.getHours() + ":" + padNumber(startJSDate.getMinutes()); } } var li = document.createElement('li'); /* if we have a link to the event, create an 'a' element */ if (entryLinkHref != null) { entryLink = document.createElement('a'); entryLink.setAttribute('href', entryLinkHref); entryLink.appendChild(document.createTextNode(title)); li.appendChild(entryLink); li.appendChild(document.createTextNode(' - ' + dateString + 'Description goes here, but on the next line.')); } else { li.appendChild(document.createTextNode(title + ' - ' + dateString)); } /* append the list item onto the unordered list */ if (startJSDate.getMonth() +1 == todaysDate.getMonth() + 1 && startJSDate.getDate() == todaysDate.getDate() + 1){ //alert (title); ul.appendChild(li); } } eventDiv.appendChild(ul); }
    mattfeury
    • mattfeury
    Rather than document.createTextNode, createElement('div') and append to that a textNode with the text.

    Looking for something else?

    Not the answer you are looking for? Search for more explanations.