Thiyagu Arockiasamy Ответов: 1

Строка-я хочу усечь текст или строку с многоточием с помощью jquery?


Как загрузить данные json в jquery с помощью html-страницы. мне нужен абзац слово короткое . например, поисковые данные Википедии ........

If i click the link Redirect to another page Paragraph full details are display. i sucessfully bind and redirect to another page.The html page for example Index.html and Newsdetails.html I need below example
My Output is:

Business Deals

Daimler India Commercial Vehicles (DICV) in association with Espirit Trucking has inaugurated a new BharatBenz dealership for its commercial vehicle brands in National Capital Region (NCR), Ghaziabad. It will cater BharatBenz trucks and buses as well as to Mercedes-Benz luxury buses. The company said in a statement, the opening of this new dealership which is owned and run by Espirit Trucking is an example of how DICV's dealer network continues to proliferate deeper into domestic market regions including tier II and tier III cities. Speaking at the inauguration of the new dealership, Sominder Singh, DICV's Vice President responsible for Domestic Sales, Product Management & Network said "We want to get even closer to our customers - in line with our continuous growth we are further expanding our sales and service network. Espirit Trucking is an experienced partner who will provide excellent sales and services to our customers from this new venture in Ghaziabad." Vivek Avasthi, Director, Espirit Trucking said, "Ghaziabad is the perfect location for this new full-fledged commercial vehicle dealership. Our investment here reflects our belief into the enormous growth opportunities for commercial vehicles in one of India's most vibrant regions, with the BharatBenz and Mercedes-Benz brands giving us the right products to be successful." The dealership will provide a host of value-added services such as cashless zero-depreciation insurance, full maintenance contracts, extended warranty, 24x7 roadside assistance, vehicle tracking systems, driver training, and on-site service.  

Я хочу вывести:
<pre lang="C#">Business Deals

Daimler India Commercial Vehicles (DICV) in association with Espirit Trucking has inaugurated a new BharatBenz dealership for its commercial vehicle brands in National Capital Region (NCR), Ghaziabad. It will cater BharatBenz trucks and buses as well as to Mercedes-Benz luxury buses. The company said in a statement...........

Пожалуйста, помогите мне....

Что я уже пробовал:

Index.html сценарий:
< script type= "text/javascript">

$(документ).готово(функция () {
отладчик;
//var id = 0;
$. getJSON('http://localhost:33804/NewsRestService.svc/NewsById/0', функция (данные) {
var out = "";
ВАР i;
для (i = 0; i < data.NewsByIdResult.длина; i++) {

var Encode = данные.NewsByIdResult[i].SourceVersion;
ВАР расшифровать = $('
'). html (Encode). text();
var SourceVersionHtml = RemoveHTMLTags(декодирование);

из += '
'
+ '
'
+ '

' + данные.NewsByIdResult[i]. NewsTopic + '

'
+ '

'+SourceVersionHtml + '

'
}
document.getElementById ("newshref"). innerHTML = out;
});
});

функция RemoveHTMLTags(content) {
var regX = /(< ([^>]+)>)/ig;
var html = контент;
ВАР подстрока = HTML-код.заменить(regX, "");
возвращаемая подстрока;
}
< / script>

Репортажи.Html Скрипт:

< script type= "text/javascript">
функция GetParameterValues(param) {
отладчик
var url = окно.расположение.с href.кусочек(окно.location.href. indexOf ('?') + 1). split ('&');
for (var i = 0; i & lt; url. length; i++) {
var urlparam = url[i]. split('=');
if (urlparam[0] == param) {
return urlparam[1];
}
}
}
$(документ).готово(функция () {
отладчик
var newsid = GetParameterValues ('newsid');
ВАР URL-адрес = "http://localhost:33804/NewsRestService.svc/NewsById/" + программа;
var out = "";
$. getJSON (url, функция (данные) {
если (данные.NewsByIdResult.длина > 0) {

var Encode = данные.NewsByIdResult[0].SourceVersion;
ВАР расшифровать = $('
'). html (Encode). text();
var SourceVersionHtml = RemoveHTMLTags(декодирование);

из += '
'
+ '
'
+ '

' + данные.NewsByIdResult[0]. NewsTopic + '

'
+ '

'+SourceVersionHtml + '

';
}

document.getElementById ("newsget"). innerHTML = out;

});
});

функция RemoveHTMLTags(content) {
var regX = /(< ([^>]+)>)/ig;
var html = контент;
ВАР подстрока = HTML-код.заменить(regX, "");
возвращаемая подстрока;
}
< / script>

1 Ответов

Рейтинг:
7

F-ES Sitecore

Google " javascript добавляет многоточие в текст"

Вот один результат но есть еще тысячи

string-я хочу усечь текст или строку с многоточием с помощью JavaScript - Stack Overflow[^]


Thiyagu Arockiasamy

Большое спасибо F-ES Sitecore. Это для меня нормально работают. Большое вам спасибо.