javascript - Change fields with jquery -
i'd change contact form fields jquery. that's normal code:
<label for="avia_3_1">nome <abbr class="required" title="richiesto">*</abbr></label>
that's jquery i'm using. have combobox, name of label should change based on user selected item. works, tag <abbr>
disappear.
//$.noconflict(); jquery( document ).ready(function( $ ) { $("#avia_1_1").change(function(){ switch($("#avia_1_1").val()){ case "privato": $("label[for='avia_3_1']").text("nome"); $("abbr[title='richiesto']").text("*"); break; case "azienda": $("label[for='avia_3_1']").text("ragione sociale"); $("abbr[title='richiesto']").text("*"); break; } }); });
you can use .html()
instead of .text()
. check updated script below..
//$.noconflict(); jquery( document ).ready(function( $ ) { $("#avia_1_1").change(function(){ switch($("#avia_1_1").val()){ case "privato": $("label[for='avia_3_1']").html('nome<abbr class="required" title="richiesto">*</abbr>'); break; case "azienda": $("label[for='avia_3_1']").html('ragione sociale<abbr class="required" title="richiesto">*</abbr>'); break; } }); });
Comments
Post a Comment