I have a label and a select dropdown list:
<label for="serviceID[1]">Service</label>
<select name="serviceID[1]" id="serviceID[1]" class="jq__pickedNewService">
<option value="" selected="selected">No Service Selected</option>
<option value="004">Service 1</option>
<option value="001">Service 2</option>
<option value="005">Service 3</option>
<option value="002">Service 4</option>
</select>
I have tried all kinds of jquery code to replace the HTML inside the label tag and I am having no success:
$('.jq__pickedNewService').change(function(){
var i = 1; //for the sake of this example
$('select.jq__pickedNewService[name="serviceID\\[' + i + '\\]"]').closest('label').html('Service Replaced'); // does not work
$('#serviceID\\[' + i + '\\]').closest('label').html('Service Replaced'); // does not work
$('#serviceID[1]').closest('label').html('Service Replaced'); // does not work
}); // end pickedNewService
#serviceID[1]causes incorrect parsing of selector..prev()did the trick. Thanks !!!!.prev()solved it in my particular case. @Regent, if you move your comment to an answer I'll choose it.