Tuesday, 15 September 2015

How do I replace “ ” with “ ” in HTML using JavaScript and jQuery? -



How do I replace “<br /><br />” with “<br />” in HTML using JavaScript and jQuery? -

i have validation summary has multiple br tags @ end below:

<div id="validationsummary1" class="alert alert-error"> lastly 4-digits of social security number not match fellow member record on file fellow member id number have entered.<br /> date of birth not match fellow member record on file fellow member id number have entered.<br /><br /> </div>

i'm trying find anytime there 2 br tags back , replace 1 below:

$('#validationsummary1').replace('<br /><br />', '<br />');

i understand there isn't replace() function. alternative simple this?

use .html() , set content passing through standard js replace().

var div = $('#validationsummary1'); div.html(div.html().replace('<br /><br />', '<br />'));

jquery

No comments:

Post a Comment