Trying to shuffle the columns of the table.
Tried the below code, but it doesn't shuffle at all.
I need the first four options to be shuffled.
window.onload = function() {
$("div.question_div").randomize("span.tdran");
};
(function($) {
$.fn.randomize = function(tree, childElem) {
return this.each(function() {
var $this = $(this);
if (tree) $this = $(this).find(tree);
var unsortedElems = $this.children(childElem);
var elems = unsortedElems.clone();
elems.sort(function() {
return (Math.round(Math.random()) - 0.5);
});
for (var i = 0; i < elems.length; i++)
unsortedElems.eq(i).replaceWith(elems[i]);
});
};
})(jQuery);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
Question 3
<div class="question_div">
<table>
<tr>
<td colspan="4">
<p>In a camp, there is a meal for 200 children or 120 men. If 150 children have taken the meal, how many men will be served with the remaining meal?</p>
</td>
</tr>
<tr>
<span class="tdran">
<td><input type="radio" name="radio3" id="checka3" value="A"></td>
<td><label for="checka3">
<p>31</p>
</label></td>
</span>
<span class="tdran">
<td><input type="radio" name="radio3" id="checkb3" value="B"></td>
<td><label for="checkb3">
<p>30</p>
</label></td>
</span>
</tr>
<tr>
<span class="tdran">
<td><input type="radio" name="radio3" id="checkc3" value="C"></td>
<td><label for="checkc3">
<p>29</p>
</label></td>
</span>
<span class="tdran">
<td><input type="radio" name="radio3" id="checkd3" value="D"></td>
<td><label for="checkd3">
<p>35</p>
</label></td>
</span>
</tr>
<tr>
<td><input type="radio" name="radio3" id="checke3" value="E"></td>
<td><label for="checke3">
<p>None of these</p>
</label></td>
</tr>
</table>
</div>
<hr>
</br>
Trying to shuffle the columns of the table.
Tried the below code, but it doesn't shuffle at all.
I need the first four options to be shuffled.
Can I get an additional side note, that how can I remove spaces between two options and between radio button & value?