JQuery : how to undo changes made on DOM ? -



JQuery : how to undo changes made on DOM ? -

i have modified cost attribute on select alter .

how can normal cost on else status ?

jquery( document ).ready(function( $ ) { $('#select_1').on('change', function() { var visit_time_val=$(this).val(); if(visit_time_val==93 || visit_time_val==95) { var adult_price=26; var child_price=10; $('#select_15 option:nth-child(2)').attr("price",adult_price); $('#select_15 option:nth-child(3)').attr("price",adult_price*2); $('#select_15 option:nth-child(4)').attr("price",adult_price*3); $('#select_15 option:nth-child(5)').attr("price",adult_price*4); $('#select_3 option:nth-child(2)').attr("price",child_price); $('#select_3 option:nth-child(3)').attr("price",child_price*2); $('#select_3 option:nth-child(4)').attr("price",child_price*3); } else { //back prices setted in db } }); });

try :

var previous; $("#select_1").one('focus', function () { // store current value on focus , on alter previous = this.value; }).change(function() { var visit_time_val=$(this).val(); if(visit_time_val==93 || visit_time_val==95) { var adult_price=26; var child_price=10; $('#select_15 option:nth-child(2)').attr("price",adult_price); $('#select_15 option:nth-child(3)').attr("price",adult_price*2); $('#select_15 option:nth-child(4)').attr("price",adult_price*3); $('#select_15 option:nth-child(5)').attr("price",adult_price*4); $('#select_3 option:nth-child(2)').attr("price",child_price); $('#select_3 option:nth-child(3)').attr("price",child_price*2); $('#select_3 option:nth-child(4)').attr("price",child_price*3); } else { //back prices setted in db $(this).val(previous ); } });

jquery

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -