के साथ शेष दावे को दिखाने/छिपाने के लिए पैराग्राफ की बाकी सामग्री को छुपाएं मेरे पास पैराग्राफ है जिसमें 500 से अधिक वर्ण हैं। मैं केवल शुरुआती 100 चरित्र प्राप्त करना चाहता हूं और बाकी को छुपा सकता हूं। इसके अलावा मैं 100 चरित्र के बगल में "अधिक" लिंक डालना चाहता हूं। अधिक लिंक के अनुच्छेद पर क्लिक करने के लिए "अधिक" टेक्स्ट को "कम" पर प्रदर्शित और संपादित करना चाहिए और "कम" पर क्लिक करना चाहिए, इसे व्यवहार को टॉगल करना चाहिए। पैराग्राफ गतिशील रूप से जेनरेट किया गया है Iwrap() का उपयोग करके इसकी सामग्री को लपेट नहीं सकता। यहां उदाहरण है कि मेरे पास क्या है और मैं क्या चाहता हूं।पैराग्राफ अनुच्छेद पहले 100 वर्ण और अधिक/कम लिंक
यह है कि मैं क्या है:
<p>It is a long established fact that a reader will be distracted by the readable
content of a page when looking at its layout. The point of using Lorem Ipsum is that
it has a more-or-less normal distribution of letters, as opposed to using 'Content
content here', making it look like readable English. Many desktop publishing packages
and web page editors now use Lorem Ipsum as their default model text.</p>
यह वह जगह है जो मैं चाहता जब डोम लोड
<p>It is a long established fact that a reader will be distracted by ..More</p>
यह वह जगह है जो मैं चाहता जब उपयोगकर्ता क्लिक "अधिक"
<p>It is a long established fact that a reader will be distracted by the readable
content of a page when looking at its layout. The point of using Lorem Ipsum is that
it has a more-or-less normal distribution of letters, as opposed to using 'Content
content here', making it look like readable English. Many desktop publishing packages
and web page editors now use Lorem Ipsum as their default model text. ..Less</p>
जब हम "कम" पर क्लिक करते हैं, तो इसे "अधिक" पर क्लिक करने पर क्या करना चाहिए।
मैं विभाजित करने के लिए jQuery का उपयोग कर रहा हूं, टुकड़ा कर रहा हूं और उस अवधि में सबस्ट्रिंग लपेटता हूं जिसे मैं छिपाना चाहता हूं लेकिन यह काम नहीं करता है।
var title = $("p").text();
var shortText = jQuery.trim(title).substring(100, 1000).split(" ")
.slice(0, -1).join(" ") + "...More >>";
shortText.wrap('</span>');
आपने क्या प्रयास किया है? शायद आप अपने प्रयासों को दिखाने के लिए कुछ कोड पोस्ट कर सकते हैं –
मैंने कोड उदाहरण जोड़ा है। var shortText मैं इसे स्पैन टैग में लपेटना चाहता हूं। लेकिन .wrap() काम नहीं कर रहा है। –