reloj olfateo central de artes: check if exits
by CarambaMoreno
HTML
<div class="papa-container">
<button class="elemento" data-create="elemento1"> Elemento 1 </button>
<button class="elemento" data-create="elemento2"> Elemento 2 </button>
<button class="elemento" data-create="elemento3"> Elemento 3 </button>
<div class="log">
</div>
<div id="resultado"></div>
<p class="status"></p>
</div>
<h5>hola</h5>
CSS
body{font-size:10px;}
#resultado{ position: absolute; display: block; right: 1rem; top: 1rem; width: auto; height: auto; }
#resultado.paso1{ background-color: yellow; }
.log{border:1px solid red;font-size:0.5rem;}
#status{ position: absolute; display: block; right: 1rem; top:5rem;}
JavaScript
jQuery(document).ready(function ($) {
$(document).on('click', '.elemento', function(){
var elemento_por_crear = $(this).data("create");
$('#resultado').append('<select class="'+elemento_por_crear+'"><option>'+elemento_por_crear+'</option></select>');
setTimeout( function(){
$('.'+elemento_por_crear).append('<option>22 '+elemento_por_crear+'</option>');
}, 1000);
setTimeout( function(){
$('.'+elemento_por_crear).append('<option>22 '+elemento_por_crear+'</option>');
}, 1000);
});
function olfateo(elemento){
if( $(elemento).length > 0 ){
console.log('existe '+ elemento);
//click al dia
}else{
setTimeout(function(){
jQuery(".log").append("<span>1 segundo</span>");
olfateo(elemento);
}, 500);
}
}
function olfateo2(elemento){
if( $(elemento).length > 0 ){
console.log('existe '+ elemento);
//value al select primera opcion
// change al value
}else{
setTimeout(function(){
jQuery(".log").append("<span>1 segundo</span>");
olfateo(elemento);
}, 500);
}
}
function olfateo3(elemento){
if( $(elemento).length > 0 ){
console.log('existe '+ elemento);
// value al select
// change al values
}else{
setTimeout(function(){
jQuery(".log").append("<span>1 segundo</span>");
olfateo(elemento);
}, 500);
}
}
// olfateo('.elemento1');
// olfateo2('.elemento1 option:nth-child(2)');
//olfateo3('.elemento2 option:nth-child(2)');
function decir_hola(){
console.log("hola");
}
function olfateoembebido(domelement,functiontorun){
if(domelement != null){
if ($(domelement).length > 0){
console.log(domelement+" exists! correr functiontorun");
functiontorun();
} else {
...