I′ve the following ajax-response which is generated by my server-sided script:
<div class="item-title3">Testname</div>
<div class="item-level">120</div>
<div class="item-binding">40</div>
<div class="item-type">Feet</div>
Now I want to find the content of the <div class="item-title3">
("Testname" in that case) and use it as a link name.
Therefore I turned the ajax data into a jQuery object to select certain elements from it. Sadly it still can′t find it.
Complete code:
<script language="javascript">
jQuery(function($) {
$("[tooltip-link]").each(function() {
let $tooltip = $(this);
let id = $tooltip.attr("data-id");
$.ajax({
url: "/datenbank/itemscript.php",
type: "GET",
data: {
"var": id
}
}).then(function(data) {
let $content = $(data);
let title = $content.find('.item-title3').text()
$tooltip.tooltip({
tooltipClass: "test",
content: data
});
$("<div class="item-title">Item-" + title + "</div>").appendTo($tooltip);
});
});
});
</script>
<a tooltip-link data-id="12555" title=""></a>
question from:
https://stackoverflow.com/questions/65885366/select-div-class-from-ajax-response 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…