I have this part of html on my form:
<label class="ideal-radiocheck-label" onclick="">
<input id="pagamento_8" class="_input " type="checkbox" onclick="half(this,value);" checked="" value="980" name="pagamento[]" style="position: absolute; left: -9999px;" autocomplete="off">
<span class="ideal-check checked"></span>
988 (980-980 €)
</label>
It is a checkbox input button that call the function half() to make something like call the next function:
function setClickedLabel(clicked,new_value){
label_e=$(clicked).parent();
label_t=$(label_e).text();
labels_t=label_t.split('-');
$(label_e).html(labels_t[0]+'-'+new_value+' €)'); <-- 1
//$(label_e).text(labels_t[0]+'-'+new_value+' €)'); <-- 2
//$(label_e).innerHTML = labels_t[0]+'-'+new_value+' €)'; <-- 3
}
Here i would change a part of the label "988 (980-980 €)" (the last 980) and the "clicked" variable is the input object that you can see inside the label element.
Using one of the three methods reported i got 2 effect. Whit 1,2 it changes the label but it removes the input element. Whit 3 it doesn't make nothing.
What function i can use? How i must fix the code to get what i need? Html can't be changed.
Maybe another alternative without appending.
tnx, j.
half()? Why you are calling it? i think you just misplaced it insteadsetClickedLabel()valuein that scope is probably undefined, but you're passingthis, so just getclicked.valueinside the function? Getting the textnode (< search for this) is somewhat more involved and requires some filtering, but should be straight forward.