how might go finding specific character , inserting line break using jquery?
the character need find hyphen - , within product title on ecommerce site , takes following format:
this title - colour
how can find dash every product title , insert line break colour name on separate line?
the exact html markup i'm using follows:
<a href="#" class="product c-3"> <div class="product-thumb"> <!-- other code in here / removed brevity --> <div class="product-title"> title - colour </div> </div> </a>
you can use replace
find -
in element's html , replace -<br />
. try this:
$('.product-title').html(function(i, v) { return v.replace('-', '-<br />'); });
you can replace '<br />'
if want remove hyphen completely.
Comments
Post a Comment