Home  >  Q&A  >  body text

javascript - Change the value of input while toggle

I now have a button that displays hidden content when clicked. This can be achieved with toggle, but how can I not separately determine whether the content is hidden, but directly replace the value in the button while displaying the hidden content in toggle? Between " " and " -" to switch between.

<input type="button" value="-" class="hsBtn">
$(".hsBtn").live("click",function(){
    $(target).toggle();
})
女神的闺蜜爱上我女神的闺蜜爱上我2710 days ago772

reply all(2)I'll reply

  • 女神的闺蜜爱上我

    女神的闺蜜爱上我2017-06-12 09:34:25

    <input type="button" value="-" class="hsBtn">
    $(".hsBtn").live("click",function(){
        var $this=$(this),
            val=$this.val();
        $this.val(val=='-'?'+':'-')
        $(target).toggle();
    })

    reply
    0
  • PHP中文网

    PHP中文网2017-06-12 09:34:25

    Then determine whether the content to be displayed is in the display state. If so, it is -, otherwise it is +

    reply
    0
  • Cancelreply