Why isn't justify with execCommand working properly? Take a look at the code below:
$('#JustifyLeft').click(function(){
document.execCommand("JustifyLeft", false, "");
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p>Select the entire text and click the button</p>
<div class="editable" contenteditable="TRUE" style="font-size: 27px; text-align: center;">
<span style="font-weight: bold; font-style: italic; text-decoration: underline;">Hi<span style="font-size: 35px;">I</span>am<span style="font-size: 18px;">Blah Blah</span>Ok</span>
</div>
<input type="button" id="JustifyLeft" value="Align Left">
After selecting the whole text and justifying it, you will notice that the underlines only remain on <text>
nodes and <span>
nodes do not have text-decoration.
Could this be a bug? Is there a way to fix it?