edit the title of specific block - custom.js
Posted: Tuesday 13 August 2019 21:51
Hi,
I have a block with wind data.
The block however has a title with too much information;
I wanted to remove a part from the title, so that 0.7 m/s, 230° zuid-west would become this: 0.7 m/s zuid-west
I had some trouble to find the right handles, but i think i already got this working and fixed with some custom js scripting, but is there an easier way to get such things done?
I have a block with wind data.
The block however has a title with too much information;
Code: Select all
<div data-id="88" class="mh transbg block_88 col-xs-3 hover" data-toggle="modal" data-target="#opengraph88">
<div class="col-xs-4 col-icon">
<em class="wi wi-wind-direction icon" style="-webkit-transform: rotate(410deg);-moz-transform: rotate(410deg);-ms-transform: rotate(410deg);-o-transform: rotate(410deg); transform: rotate(410deg);"></em>
</div>
<div class="col-xs-8 col-data"><strong class="title">0.7 m/s, 230° zuid-west</strong></div>
</div>
I had some trouble to find the right handles, but i think i already got this working and fixed with some custom js scripting, but is there an easier way to get such things done?
Code: Select all
$("div[data-id=88] div.col-data").each(function() {
var orgtext = $("div[data-id=88] .col-data .title").text();
var cuttext = orgtext.replace(/\,.*° /, '');
$(this).html = $("div[data-id=88] .col-data .title").text(cuttext);
});