Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <h2>Example example example example example</h2>
- <h2>Example</h2>
- $(document).ready(function(){
- var dtl = $('.h2').text().length;
- if(dtl>10){
- $('.h2').text().length = 10;
- $('.h2').text($('.h2').text()+"...");
- }
- });
- $(document).ready(function(){
- var dtl = $("h2").text().length;
- if(dtl>10){
- $('h2').text($('h2').text().substr(0,10)+"...");
- }
- });
- $(document).ready(function(){
- $("h2").each(function() {
- if($(this).text().length > 10) {
- $(this).text($(this).text().substr(0,10)+"...");
- }
- });
- });
- $("h2").each(function() {
- var dtl = $(this).text().length;
- //rest of your code goes here
- if(dtl>10){
- var res = $(this).text();
- res = res.substring(0, 4); //apply your logic here what ever you want pass (0, 10)
- $(this).text(res +"...");
- }
- });
- <h2>This tag contains more than 10 characters</h2>
- $(document).ready(function () {
- var len = $("h2").text().length;
- var text = $("h2").text();
- if (len > 10) {
- var stext = text.substring(0, 10);
- $("h2").text(stext).append("...");
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement