Forums

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

Home Forums JavaScript "Now you see me" and keep seeing me

  • This topic is empty.
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #191291
    hetaera
    Participant

    Regarding the display: none writeup (https://css-tricks.com/places-its-tempting-to-use-display-none-but-dont/), I’d like to know how to use this more than once on a page.

    For instance, I have a page of bios, and the design calls for each bio to initially only show the first paragraph, then optionally click “show more” to expand the rest.

    #191293
    Paulie_D
    Member

    It’s not clear what the actual issue here is but JS/JQ will let you target individual elements for the same function.

    Do you have a brief example you could show us in Codepen.io?

    #191294
    hetaera
    Participant

    Just picture:

    Bio one. (read more)

    Bio two. (read more)

    etc.

    The script as it is will effect all the show/hide content, instead of one treating them individually.

    #191295
    Paulie_D
    Member

    I can picture it…now if you provide the code we can make a start…but your starter is with the Jquery this keyword.

    http://learn.jquery.com/javascript-101/this-keyword/

    #191296
    hetaera
    Participant

    Ah right, that’s in the script I often use:

    The problem with it though is the fact that it simply uses display: none.

    #191299
    hetaera
    Participant
    #191302
    Paulie_D
    Member
    #191303
    hetaera
    Participant

    Hmm, looks close, but now they won’t close.

    #191304
    Paulie_D
    Member

    I just used the script from the article linked…which, as I recall, did not include a ‘closing’ option.

    It suggested a method not a complete solution.

    I’m sure you can figure out a way to adapt what you have to toggle open and closed.

    #191305
    hetaera
    Participant

    Thanks for the help, I’ll keep at it.

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