简体   繁体   English

jQuery无法使用已加载的内容

[英]Jquery not working with loaded content

I'm using jQuery .load to load content into my page which works fine, but my ellipsis jQuery library no long works for the loaded content. 我正在使用jQuery .load将内容加载到页面中,效果很好,但是我的省略号jQuery库不再适用于加载的内容。 The ellipsis JQuery added '...' at the end of my paragraph, but no longer works because it is now loaded content. 省略号JQuery在我的段落的末尾添加了“ ...”,但由于它现在已加载内容而不再起作用。

<script>
   $(document).ready(function() {
       $('.article1 p').ellipsis();   // worked before using .load
       $(".article1").load("/inc/latest-articles.asp #article1");    
   });
</script>

Is there a trick I'm missing? 我有想念的招吗? Thanks for your time! 谢谢你的时间!

Load the document first so that $('.article1 p') isn't empty when you call your plugin : 首先加载文档,以便在调用插件时$('.article1 p')不为空:

$(".article1").load("/inc/latest-articles.asp #article1", function(){
   $('.article1 p').ellipsis();   
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM