0
  $("#aFilter-Type").text(SelectedProductType);
    if ($('#dvFilter-Type').css('display') == 'none') {
        $("#dvFilter-Type").css("display", "block")
        Count = Count + 1;
    }

I want to get count of "SelectedProductType" if count is greater than 10 than I want to suppress that for example my text is "SelectedProductType" than I want to show "SelectedPr..." this text any idea please

Andy
  • 95
  • 1
  • 3
  • 14
  • Use [`text-overflow: ellipsis`](https://developer.mozilla.org/en-US/docs/Web/CSS/text-overflow), css property. The way you are trying to get ellipsis is very confusing. Explain why are you trying to do like this? – Mr_Green Aug 05 '13 at 05:32

2 Answers2

0

Taken from this question:

How Can I Truncate A String In jQuery?

var title = "This is your title";

var shortText = jQuery.trim(title).substring(0, 10)
    .split(" ").slice(0, -1).join(" ") + "...";
Community
  • 1
  • 1
oshikryu
  • 257
  • 1
  • 13
0

You can use the native JS function substr(), here is an example:

<div id="element">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore...</div>

<script>
    jQuery(document).ready(function($) {

        threshold = 10;

        element = $("#element");

        el_start = element.text().substr(0, threshold);
        el_end = element.text().substr(threshold);

        element.text(el_start + '...+ ' + el_end.length + ' more characters.');
    });
</script>

<!-- The result is: Lorem ipsu...+ 93 more characters. --> 

Preview: http://jsfiddle.net/AckHb/

Nabil Kadimi
  • 10,078
  • 2
  • 51
  • 58