Replace Div Content onclick

前端 未结 6 1001
名媛妹妹
名媛妹妹 2020-12-06 07:48

I know nothing about jQuery but want to achieve something really important.

I want to have a button/link that will replace the div content and if I press that button

6条回答
  •  萌比男神i
    2020-12-06 08:21

    Try This:

    I think that you want something like this.

    HTML:

    My Content 1

    jQuery:

    $('#btnClick').on('click',function(){
    if($('#1').css('display')!='none'){
    $('#2').show().siblings('div').hide();
    }else if($('#2').css('display')!='none'){
        $('#1').show().siblings('div').hide();
    }
    });
    


    JsFiddle:
    http://jsfiddle.net/ha6qp7w4/1113/ <--- see this I hope You want something like this.

提交回复
热议问题