The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript ‘Load All’ removing html — help?

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #45948

    Hi there,

    I have a “load all” script in jQuery. Inside this div, I have a bunch of headings, paragraphs, tables, basic HTML. The problem is, when you click on “load all”, that HTML is stripped. How do I make it so that the information is retained?

    You can see what I mean by going here:

    Hmm… thoughts?


    Probably not the most elegant solution but I wanted to see if I could do it :P

    First you need to grap the **html** rather than _ text_ from .load-all otherwise it strips out all the html tags.

    Further down you’ll see I _append_ **’.morecontent’** because

    > var html = c + ‘‘ + h + ‘ ‘+moretext+’‘;

    causes some problem where it shortens only the first paragraph to 300 characters and then displays all the rest.

    My solution has a problem where the closing p tag is still used after 300 characters. To get around the paragraph space this would cause when displaying **’.morecontent’** I’ve targeted the first p tag to **display: inline**. For this example I also made the ‘.morelink’ display:block to drop it below the text.

    Edit: I changed the url above.


    I also changed this:

    > $(this).parent().prev().toggle();


    > $(this).parent().find(‘.morecontent span’).toggle();

    to get the toggle to work


    Wow, thank you so much waylaid! You are wonderful :) Smart.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.