π·οΈSuffixes and prefixes
Convert an open text label into a suffix or prefix


How to use it...
Variables
Variable name
Description
Example
Examples



Last updated
Convert an open text label into a suffix or prefix





Last updated
function add_label({question_code, type = "suffix"} = {}) {
label = document.querySelector("#q_" + question_code + "_card > label");
label_text = label.innerText;
label.remove();
input = document.querySelector("#p_" + question_code + "_1");
container = document.querySelector("#q_" + question_code + "_card");
if (type == "suffix") {
wrapper = `
<div class="input-group">
` + input.outerHTML + `
<div class="input-group-append">
<span class="input-group-text" style="margin-top: 15px">` + label_text + `</span>
</div>
</div>
`
} else if (type == "prefix") {
wrapper = `
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text" style="margin-top: 15px">` + label_text + `</span>
</div>
` + input.outerHTML + `
</div>
`
}
input.remove();
container.innerHTML += wrapper;
}
/* Change this part of the code with your parameters */
add_label({
question_code : "Q1",
type : "prefix"
});add_label({
question_code : "Q1",
type : "prefix"
});add_label({
question_code : "Q1",
type : "prefix"
});add_label({
question_code : "Q1",
type : "prefix"
});
/* OR */
add_label({
question_code : "Q1",
type : "suffix"
});add_label({
question_code : "Q1",
type : "prefix"
});add_label({
question_code : "Q1",
type : "suffix"
});