jquery - javascript change color of textbox -


i have code wont work. problem be? syntax wrong or whole method wrong?

<input checked="checked" class="form-field" id="iscurrentlysmokingrightnej" name="iscurrentlysmokingright" type="radio" value="nej"> <input class="form-field" id="iscurrentlysmokingrightja" name="iscurrentlysmokingright" type="radio" value="ja">     <input id="iscurrentlysmokingrighttextbox" name="iscurrentlysmokingright" type="text" style="background-color: rgb(0, 255, 0); float: right; width: 50px;"> 

javascript:

 $(document).on("change", "iscurrentlysmokingrightnej", function() {     var elem = document.getelementbyid("iscurrentlysmokingrightnej");     var ele = $("#iscurrentlysmokingrighttextbox");     if (elem.checked) {         ele.css("background-color", "rgba(0, 255, 0, 1)");         ele.css("float", "right");         ele.css("width", "50px");      } });     $(document).on("change", "iscurrentlysmokingrightja", function() {         var elem = document.getelementbyid("iscurrentlysmokingrightja");         var ele = $("#iscurrentlysmokingrighttextbox");         if(elem.checked){             ele.css("background-color", "rgba(255, 0, 0, 1");//röd             ele.css("float", "right");             ele.css("width", "50px");         }  }); 

you missed # in front of id selector

 $(document).on("change", "#iscurrentlysmokingrightnej", function() {                       //---^---here 

same goes rest..


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -