I have matching text in different parts of a document. The first is a set of "tags" in a table like so:
<div id="my-div">
<div><a href="#">tag 1</a></div>
<div><a href="#">tag 2</a></div>
</div>
Then in several other parts of the document, I have a hidden element after the items I want to highlight when the matching link is selected like so:
<div class="hide-me">tag 1</div>
Then my click function is like this:
$('#my-div a').click(function() {
var txt = $(this).text();
console.log(txt);
});
The output is an empty string, but I’m not sure why.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…