Reputation: 6513
I'm using phonegap and am very new to this.
script source:
<script src="http://www.transfermate.com/en/exchange_rates_api.asp"></script>
I'm trying to get rid of the < br >s in the div 'currency_converter_calculator_subscribe_form_under_info'
My attempt so far:
$('#currency_converter_calculator_subscribe_form_under_info.form_under_info calculator_subscribe_form_under_info br').remove();
EDIT The problem is the script produces a string like this:
4 USD United States of America Dollars
=
3.1308 EUR Euro
I need the line to not take up as much space, so I need to get rid of the < br >s or shorten the string. I know that after the number there will be a 3 character length acronym always e.g. USD, EUR. It would also work to parse out the part of the string after this char code and before the = sign either but I can't reference the label properly or so it would seem:
$('#currency_converter_calculator_subscribe_form_under_info').val('testing');
Best possible solution would be:
4 USD = 3.1308 EUR
Any help appreciated
Upvotes: 0
Views: 155
Reputation: 554
function removeBr(container) {
var brs = container.getElementsByTagName("br");
for (var i = 0; i < brs.length; i++) { brs[i].parentNode.removeChild(brs[i]); }
}
where container is your container ID
var container = document.getElementById('currency_converter_calculator_subscribe_form_under_info');
removeBr(container);
Does this work for you?
Or if you don't wanna have an extra function you could use this in your CSS file to just make the
tags invisible
br { display: none; }
or #currency_converter_calculator_subscribe_form_under_info br { display: none; }
to make it effective only in the container you want.
Or you can also do a regex replace on your variable:
var str = "4 USD<br> = <br>3.1308 EUR";
var newStr = str.replace(/<br\s*[\/]?>/gi, " ");
Or in Jquery:
var str = "4 USD<br> = <br>3.1308 EUR";
var regex = /<br\s*[\/]?>/gi;
$("#mydiv").html(str.replace(regex, " "));
Upvotes: 1
Reputation: 6933
You can use find() to search for all br tags in that div and remove them
$(document).ready(function() {
$('.currency_converter_calculator_subscribe_form_under_info').find('br').remove();
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<div class="currency_converter_calculator_subscribe_form_under_info">
Lorem ipsum dolor sit amet,
<br/>consectetur adipisicing elit.
<br/>Obcaecati quos tenetur dolorum doloribus rerum
<br/>ex ab dignissimos adipisci esse
<br/>consequuntur facilis ipsam numquam
<br/>officia officiis sit rem sint
<br/>eligendi laudantium.
</div>
Upvotes: 0