Change DIV contents using jQuery when link clicked

后端 未结 6 1551
梦毁少年i
梦毁少年i 2021-01-26 02:15

Thank you, in advance, for those who answer =)
I\'m trying to switch between divs when i click the links with the respective class (as follow on the code bellow). It works f

6条回答
  •  礼貌的吻别
    2021-01-26 03:05

    Rui,

    I would do something like this:

    HTML:

    JQUERY:

    $(".cont").click(function() {
    if ($(this).hasClass("info")){
       $("#content-title").text("Your text goes here"); //Set some text in content-title element
       $("#content-text").text("Your text goes here"); //Set some text in content-text element 
       $(".content").slideToggle(500); //Show the content element class
    
    }
    });
    

提交回复
热议问题