1

I am creating elements using:

$('#articleview').append(articles);

I need to apply the dotdotdot plugin to this dynamically created html

$(document).ready(function() {
  $(".ellipsis").dotdotdot();
});

but it's not working in dynamically created html

Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
Vinoth
  • 23
  • 5

2 Answers2

1

After the $('#articleview').append(articles);

call -

$(".ellipsis").dotdotdot();

And this should work...

dotdotdot() did it's work for first time the document was loaded. When you changed the content, it needed to be called again.

Vishal Kumar Sahu
  • 1,232
  • 3
  • 15
  • 27
0

Always call plugins after dom ready other wise plugin unable to find markup and fail.

var articles='Lorem Ipsum is simply dummy text Lorem Ipsum is simply dummy text Lorem Ipsum is simply dummy text Lorem Ipsum is simply dummy text';
$('#wrapper').append(articles);
$(".ellipsis").dotdotdot();
#wrapper {
    width: 100px;
    height: 20px;
  
}
  
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
  <script src="http://dotdotdot.frebsite.nl/js/jquery.dotdotdot-1.2.1.js"></script>
<div id="wrapper" class='ellipsis'></div>
4b0
  • 21,981
  • 30
  • 95
  • 142