Replace Div Content onclick

前端 未结 6 1003
名媛妹妹
名媛妹妹 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条回答
  •  庸人自扰
    2020-12-06 08:04

    Here's an approach:

    HTML:

    My Content 1

    jQuery:

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


    JsFiddle:
    http://jsfiddle.net/ha6qp7w4/
    http://jsfiddle.net/ha6qp7w4/4 <--- Commented

提交回复
热议问题