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

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -