I\'m trying to get the content of a span when a button is clicked. This is the html:
Depending on how many spans you have but if the span will always come directly after the button then the .next('span')
will work. If you plan on placing the button anywhere else within the same parent div then you will need to navigate the dom to find it.
$('selector').click(function() {
$(this).parent().find('span');
)};
Also it may be best to add a targetable class or attribute to the span to target it better incase you do plan on a more complex dom or multiple spans.
Text Here
$('button.select-location').click(function() {
var span_val = $(this).parent('div').find('span.clicktarget').html();
});
Hope this helps