Tuesday, April 24, 2012

jQuery: $(element).text() doesn't work

Why isn't this working? I've searched Stackoverflow and jQuery API and it should work. Instead I get an empty string :(



function a(){
var div=document.createElement("div");
div.innerHTML='<a class="aClass" href="javascript:showMyText(this)">Link Text</a>';

var parent_div=document.getElementById('dinamicni_div');
parent_div.appendChild(div);
}

function showMyText(link){
var txt=$(link).text();
alert(txt);
}




No comments:

Post a Comment