I wish to replace spaces in something like this:
<span>5</span>SPACE<image href="mtgsymbol.png" />
but when I do so using:
card_cost=card_cost.replace(/\s/g,"");
it messes my css all up and the objects stack on each other like their position is changed to absolute.
How do I replace the spaces without breaking my css or document flow?
Example code:
Javascript:
card_cost=document.getElementById('card_cost').value;
if(card_cost)
{
card_cost=card_cost.replace(/\d+/g,"<span class='card_costnum'>$&</span>");
*breaks styling*card_cost=card_cost.replace(/\s/g,"");*breaks styling*
}
document.getElementById('output').innerHTML+="<div class='card'>"+"<span class='card_cost'>"+card_cost+"</span>";
CSS:
.card_name,.card_image,.card_cost,.card_type,.card_subtype,.card_rarity,.card_rules,.card_flavor,.card_strength,.card_num,.card_lower,.card_costnum
{
position:relative;
z-index:1;
}
.card_cost
{
display:inline-block;
float:right;
clear:right;
}
.card_costnum
{
position:relative;
display:inline-block;
text-align:center;
vertical-align:middle;
background-image:url("numsymbol_small.png");
background-repeat:no-repeat;
width:12px;
height:12px;
margin:1px;
top:-4px;
}
.innerHTML+=.... It's a terrible thing to do to your DOM."in the url, etc. have a look at codebeautifier.com