0
Which JS framework would prompt me to create HTML objects dynamically?
For example: I need to create a "btn-example" class button that references the Google website link (by clicking, open the site). However, I will do this only when a given boolean variable is true. The algorithm for inserting the element into the DOM tree would be:
if ( variavelBooleana ) {
var botao = document.createElement('input')
botao.value = 'Google'
botao.class = 'btn-teste'
botao.onclick = function () { window.location.href = 'google.com' }
document.body.appendChild(botao)
}
Disregard mistakes because what I really want is to do this:
if ( variavelBooleana )
frameworkEspecificoQueFazIsto.addElemento('input',{class: 'btn-teste', value: 'Google', onclick: function () { window.location.href = 'google.com' } })
I hope you have understood and can help me. I thank you in advance.
I don’t understand why you use a
input
if the goal is to create a button (and if it is a link, it should be an anchor,<a>
, not a button), but anyway, why not just implement this function you want instead of using a framework?– Woss
I am looking for this framework for a company project in which I work. We have a module that should store a JS string to be used dynamically (I won’t go into detail for professional ethics). I need the framework as soon as possible, because it is not just a simple input or button that we will use, but perhaps an img or form, etc... Understands?
– Felyp Henrique Fernandes
Apparently it is easier to "develop" than to "look for something ready".
– LipESprY