Slide: add line break

Hello I wish to add line breaks in the subtitles of my slides.


I tried this method but it makes the text on one slide repeat in every slide. I wish to put a different text in each slide. How can i do this?
Thanks

Hello there,

Can you share your final code to pastebin.com and update me with its link? So, I can try and make some revisions if needed. It would be good if you could share a link to your website here as well, so I can compare when troubleshooting the code.

Regards,
Kharis
aThemes Support

Hello, i have used the exact same code and this happened.
title

As you can see it has put the different titles on top of each other.

Later i tried using this code for the subtitle.

It instead put the text from one slide next to the other.

I’m sorry my website isn’t public yet. I can’t share the link with you.

No problem. Can you share your final code to pastebin.com and update me here with its link?

Regards,
Kharis
aThemes Support

Hi, here’s the code

(function($){

  var slideTitle    = $('.main-slider .slider-item p').text();
  var newSlideTitle = slideTitle.replace('/', '<br />');

  $('.main-slider .slider-item p').html(newSlideTitle);

})(jQuery);

Hello there,

Thank you for sharing the code.

Please try replacing it with this one:

    ;(function($) {

       'use strict'

       if( $('.main-slider .slider-item').length ){

        $('.main-slider .slider-item').each(function(){

          var slideTitle    = $(this).find('p').text();
          var newSlideTitle = slideTitle.replace('/', '<br />');

          $(this).find('p').html(newSlideTitle);

        });

      }

    })(jQuery);

Let me know how it goes.

Regards,
Kharis
aThemes Support

Hello, thank you it works now. the only problem is that it only allows me to use the “/” once as a line break. if i put another “/” it doesnt do anything. Is there anyway of solving this? thank you

Hello there,

Thank you for getting back.

Try this code:

    ;(function($) {

       'use strict'

       if( $('.main-slider .slider-item').length ){

        $('.main-slider .slider-item').each(function(){

          var slideTitle    = $(this).find('p').text();
          var newSlideTitle = slideTitle.replaceAll('/', '<br />');

          $(this).find('p').html(newSlideTitle);

        });

      }

    })(jQuery);

Regards,
Kharis
aThemes Support

Hello. It’s working now. Thank you!!

You’re welcome!

Please let us know in a new topic if you have any further questions, or if we can provide you with any other assistance.

Regards,
Kharis
aThemes Support