I have the following html that renders within an ASP.NET Repeater:
<div class="divDE-item" onclick="addFilter(this);">
<span class="spnKey">Some key</span>
<div>1234</div>
</div>
I realize that having an onclick on the outer div may not be the most graceful jQuery-centric approach. However, considering my situation, it works well.
Here is my addFilter() function:
function addFilter(oDiv) {
$(document).ready(function() {
// Get and set the prefix text for the label. i.e. "Key = "
sDEName = $(oDiv).find("span").text();
$('#<%= lblDEName.ClientID %>').text(sDEName + " = ");
// Get the actual filter text value. i.e. "1234"
// sFilter = $(oDiv).text();
var sFilter = $(oDiv).filter(function() {
var filtered = $(this).not(".spnKey");
return filtered
});
$('#<%= txtValue.ClientID %>').val(sFilter);
});
}
The goal is for the output to appear like this (with 1234 being the value of a textbox):
Some key = 1234
However, the output I'm getting is: Some key = Some key 1234