Jquery add to h2 if h2 contains this word

if h2 has the word ply, I want to add a gap.

the names are dynamically called, the site is html, so I can not use php for anything.

heres h2

11 / 400-5 4 TIRES FOR EXPERIMENTAL TIRES FOR USING QUALITY

want it to look like

11 / 400-5 4 PLY
EXPERIMENTAL TIRE FOR AIRCRAFT

therefore, any heading that contains the word PLY will add a gap immediately after the word.

maybe pretty easy for all of you there =)

+5
source share
3 answers

Example: http://jsfiddle.net/DbJ2V/

$('h2:contains(" PLY ")').html( function(i,htm) {
     return htm.replace(" PLY ", " PLY<br/>");
});
+7
source

Try replying instead of comments:

$("h2:contains('PLY')").each(function() {
    $(this).html($(this).html().replace(/(\WPLY\W)/g, "$1<br />"));
});

h2 'PLY', , (, -PLY , _PLY , , , ), <br />.

+2

Try:

$(document).ready(function() {
    $("#content h2:contains(' PLY ')").each(function(k,v) {
        t = $(v).text();
        $(v).html(t.replace(" PLY ", " PLY<br/>"));
    }); 
});
0
source

All Articles