简体   繁体   中英

Change Text on slideToggle

Here is the jfiddle: http://jsfiddle.net/RHbzv/

What I am trying to do is that when the answer is displayed, 'See more' turns into 'See less' but I can't seem to get it right.

I have tried:

  $('.see_more').on('click', function(){
    if ($(this).text() == 'See more'){
      $(this).text('See less')
    } else {
      $(this).text('See more')
    }
    $('.answer').slideToggle('slow')
  })

Any ideas???

  $('.see_more').on('click', function(){
  if ($(this).html() == 'See more'){
  $(this).html('See less')
  } else {
  $(this).html('See more')
  }
  $('.answer').slideToggle('slow')
  })

see the demo here http://jsfiddle.net/Junkie/RHbzv/1/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM