Unable to understand in QBuilder parameter syntax | XM Community
Skip to main content
I have the found following JS code. I'm unable to understand a couple of things:



- What is QBuilder for other than creating HTML tags inside of the JS?

- What are the last two parameters inside of the function call doing? The `{}` and the variable after it don't seem to make sense. Especially because the last param appears without square brackets in the first invocation, and with square brackets in the second invocation.



```

var messageText = 'SAMPLE TEXT';

var c = this.questionContainer;

var tc = QBuilder('span',{},messageText);

var ic = QBuilder('div',{},[tc]);

$(c).appendChild(ic);

```
Hii @welork ,



The {} is used to assign CSS properties.

e.g.



choiceInput.parentNode.appendChild(QBuilder('span',{style:"color:blue"},msgText));



And [] is used when u want to insert new tag inside.
Is there documentation on QBuilder anywhere? I have been unable to locate that even for PrototypeJS
You can find another example of qbuilder in attached.
@bansalpeeyush29 I asked for a clarification of QBuilder, not examples, but thank you.



I think QBuilder can be safely assumed to be a maker of HTML tags within JavaScript. The first argument is the tag name, followed by the second as the attributes, and the third as the element going in-between opening and closing tags.

Leave a Reply