I am dynamically generating content – div’s with links in them. Link should bring up a popup containing link’s text when clicked (showMyText function). Instead I get an empty string 🙁
Why isn’t this working? I’ve searched Stackoverflow and jQuery API and it should work.
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);
}
If you’re using jQuery to get the
text()why not use it for everything else too?Example fiddle