Having a hard time adding an element into another element. my approach is unique. basically the user either enters a selector or by default it is the document.
so we have 2 buttons, one which specifies a selector and one which does not.
<button onClick="callFunction({where:'#test'})"> Test selector</button>
<button onClick="callFunction()"> default</button>
and the function "callFunction":
function callFunction(arguments){
scope= (arguments.where===undefined? $(document) : $(arguments.where));
createElementIn(scope);
}
then calls the createElementIn(scope) function and creates the element in the selector given
function createElementIn(scope){
var newdiv = document.createElement('div');
$(newdiv).css("position", "absolute");
$(newdiv).css("left", "500px");
$(newdiv).css("bottom", "500px");
$(newdiv).css("display", "block");
newdiv.innerHTML = str;
scope.append(newdiv);//Over here, it does not append
}
I have a feeling im mixing up when to do $(scope)... and when to leave it scope... document.body.appendChild works but i cant pass document.body into the scope. please, whats the right approach to solving this?