Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Aug 17 09:32
    User @bjorno43 unbanned @linkin-park
  • Jun 20 21:19
    @bjorno43 banned @shenerd140
  • Apr 25 17:13
    @mstellaluna banned @cmal
  • Jan 08 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
  • Jul 03 2018 12:28
    @bjorno43 banned @vbvmatta
  • Jun 29 2018 13:54
    @bjorno43 banned @OGTechnoBoy
Colin
@finkbeca
Could you give an example? @korzo
I don't have much experience working with js
korzo
@korzo
@korzo or add type="button" to your <button>
default type for button is submit
iso
@iso1048
@rafaelmonroy var text = $('#quote-holder').html(); maybe
Colin
@finkbeca
@korzo so now when I load it in codepen it shows [object HTML Collection] but when i try this in a local host nothing happens
rafaelmonroy
@rafaelmonroy
@gothamknight that worked but it brings a long the <br> tags
korzo
@korzo
@finkbeca bacause you append HTML Node, not text
Jorge
@flawedLogic506
yeah i was gonna say that append looks a little bit off ..
why not use jquery?
iso
@iso1048
@rafaelmonroy that is because you have the <br> tag in the html of that div
rafaelmonroy
@rafaelmonroy
@gothamknight is it possible to filter them out?
Colin
@finkbeca
@korzo Could you explain?
@OrangeKulture I didn't know jquery would be of use
and I dont know jquery lol
Jorge
@flawedLogic506
yeah jquery would make it a lot easier
first off, what are you trying to do ?
korzo
@korzo
@finkbeca item is array of objects, not text
Jorge
@flawedLogic506
are you trying to type something, click add and have that added to a list? right
korzo
@korzo
@finkbeca you need item[0].value
Colin
@finkbeca
@OrangeKulture Yes
iso
@iso1048
@rafaelmonroy try this:
var text=$('#quote-holder').html();
text = text.replace('<br>','\n');
Colin
@finkbeca
@korzo Thank you korzo for trying to help but I think I need to take a step back
CamperBot
@camperbot
finkbeca sends brownie points to @korzo :sparkles: :thumbsup: :sparkles:
:cookie: 423 | @korzo |http://www.freecodecamp.com/korzo
korzo
@korzo
@finkbeca add console.dir(item); after
@finkbeca and you will understand
Colin
@finkbeca
@korzo but I dont understand what you are saying currently
iso
@iso1048
@rafaelmonroy
var text=$('#quote-holder').html().replace(/<br>/g,'\n');use that
Colin
@finkbeca
@finkbeca I understand you are telling me to add things but if I dont understand the why , it is no help. Thanks for the attempt to help I appreciate it , it is just not helping lol.
CamperBot
@camperbot
sorry finkbeca, you can't send brownie points to yourself! :sparkles: :sparkles:
korzo
@korzo
@finkbeca document.getElementsByClassName returns array
of objects
input elements (<input> ) is object in javascript
You can get what is written in input from value property
rafaelmonroy
@rafaelmonroy
@gothamknight thanks man! i replaced the br with “” instead of \n what is \n?
CamperBot
@camperbot
rafaelmonroy sends brownie points to @gothamknight :sparkles: :thumbsup: :sparkles:
:cookie: 406 | @gothamknight |http://www.freecodecamp.com/gothamknight
piteto
@piteto
@rafaelmonroy can you use .text() instead of .html()?
iso
@iso1048
@rafaelmonroy no worries. /n is a line break, but it does not seem to work exactly as planned
korzo
@korzo
@finkbeca So to make your script work you need to replace line 14 with var item = document.getElementsByClassName("todolist")[0].value;
iso
@iso1048
@piteto did not even think of that.
piteto
@piteto
in js, we would just use textContent instead of innerHTML if we don't want the html
rafaelmonroy
@rafaelmonroy
@piteto yeah that works too, then there is no need for the replace. good one, thanks guys!
CamperBot
@camperbot
rafaelmonroy sends brownie points to @piteto :sparkles: :thumbsup: :sparkles:
:warning: @piteto's account is not linked with freeCodeCamp. Please visit the settings and link your GitHub account.
piteto
@piteto
assume it's similar in jquery
Jorge
@flawedLogic506
@finkbeca try this: Example
@finkbeca if u open the console, you'll see whatever you enter in the text field
Colin
@finkbeca
@OrangeKulture Thanks, any way to display it on screen?