jquery - How to apply CSS class to a split string -
i have html content generated using xsl:
<span class="hrsdisp">sunday: closed</span> <span class="hrsdisp">monday & tuesday: 8 - 7 pm</span> <span class="hrsdisp">tuesday & wednesday: 7 - 7 pm</span> <span class="hrsdisp">mon, wed, & fri: 7 - 5:30 pm</span>
xsl:
<span class="hrsdisp"> <xsl:value-of select="txthours" /> </span>
i trying set text before :
bold using jquery. have next gets string alert statement displays 1 alert, though there multiple entries:
$(function () { var thetime = $(".hrsdisp").text().split(":")[0]; alert(thetime); });
the above doesn't work expected doesn't throw error either. added next line add together class:
thetime.addclas("setbold");
and uncaught error exception in console.
the final script thought work is:
$(function () { var thetime = $(".hrsdisp").text().split(":")[0]; alert(thetime); thetime.addclass("setbold"); });
instead page not displayed correctly , error in console.
please help me resolve issue.
try below xsl rule instead of javascript manipulation:
<span class="hrsdisp"> <strong><xsl:value-of select="substring-before(txthours, ':')" /></strong>: <xsl:value-of select="substring-after(txthours, ':')" /> </span>
alternatively can utilize jquery in way:
$(function () { $(".hrsdisp").html(function(i, old) { homecoming '<strong>' + old.split(":").join('</strong>:'); }); });
jquery html css xslt
No comments:
Post a Comment