3v4l.org

run code in 300+ PHP versions simultaneously
<?php echo ' $(document).ready(function(){ $(\'.ingBox:first\').hide(); $(\'#plus\').click(function(){ var newbox = $(\'.ingBox:first\').clone(); $(\'#ings\').append(newbox); if($(\'#add_id\').val() in all_ings){ var item = all_ings[$(\'#add_id\').val()]; newbox.find(\'[name="id_ingredient[]"]\').val(item.id_ingredient); newbox.find(\'[name="name[]"]\').attr(\'readonly\',\'readonly\').val(item.name).change(); newbox.find(\'[name="description[]"]\').attr(\'readonly\',\'readonly\').val(item.description); newbox.find(\'[name="cms_name[]"]\').attr(\'readonly\',\'readonly\').val(item.cms_name); } newbox.show(); $(\'#add_id\').val(\'0\'); }); $(\'.left\').live(\'click\', function(){ var that = $(this).parents(\'.ingBox\'); that.fadeOut(\'slow\', function(){ that.prev().before(that); that.fadeIn(); }); }); $(\'.right\').live(\'click\', function(){ var that = $(this).parents(\'.ingBox\'); that.fadeOut(\'slow\', function(){ that.next().after(that); that.fadeIn(); }); }); $(\'.enable\').live(\'click\', function(){ var that = $(this).parents(\'.ingBox\'); that.find(\'[name="id_ingredient[]"]\').val(0); that.find(\'[name="name[]"]\').removeAttr(\'readonly\'); that.find(\'[name="description[]"]\').removeAttr(\'readonly\'); that.find(\'[name="cms_name[]"]\').removeAttr(\'readonly\'); $(this).parent().hide(); }); $(\'.minus\').live(\'click\', function(){ $(this).parents(\'.ingBox\').remove(); }); $(\'.unfold\').live(\'click\', function(){ if($(this).parents(\'.ingBox\').find(\'.col\').is(":visible")){ $(this).parents(\'.ingBox\').find(\'.col\').slideUp(); } else { $(\'.col\').hide(); $(this).parents(\'.ingBox\').find(\'.col\').slideDown(); } }); $(\'[name="name[]"]\').live(\'change\', function(){ $(this).parents(\'.ingBox\').find(\'.buttons span\').text($(this).val()); }); }); ';
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.10, 7.2.0 - 7.2.33, 7.3.12 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
$(document).ready(function(){ $('.ingBox:first').hide(); $('#plus').click(function(){ var newbox = $('.ingBox:first').clone(); $('#ings').append(newbox); if($('#add_id').val() in all_ings){ var item = all_ings[$('#add_id').val()]; newbox.find('[name="id_ingredient[]"]').val(item.id_ingredient); newbox.find('[name="name[]"]').attr('readonly','readonly').val(item.name).change(); newbox.find('[name="description[]"]').attr('readonly','readonly').val(item.description); newbox.find('[name="cms_name[]"]').attr('readonly','readonly').val(item.cms_name); } newbox.show(); $('#add_id').val('0'); }); $('.left').live('click', function(){ var that = $(this).parents('.ingBox'); that.fadeOut('slow', function(){ that.prev().before(that); that.fadeIn(); }); }); $('.right').live('click', function(){ var that = $(this).parents('.ingBox'); that.fadeOut('slow', function(){ that.next().after(that); that.fadeIn(); }); }); $('.enable').live('click', function(){ var that = $(this).parents('.ingBox'); that.find('[name="id_ingredient[]"]').val(0); that.find('[name="name[]"]').removeAttr('readonly'); that.find('[name="description[]"]').removeAttr('readonly'); that.find('[name="cms_name[]"]').removeAttr('readonly'); $(this).parent().hide(); }); $('.minus').live('click', function(){ $(this).parents('.ingBox').remove(); }); $('.unfold').live('click', function(){ if($(this).parents('.ingBox').find('.col').is(":visible")){ $(this).parents('.ingBox').find('.col').slideUp(); } else { $('.col').hide(); $(this).parents('.ingBox').find('.col').slideDown(); } }); $('[name="name[]"]').live('change', function(){ $(this).parents('.ingBox').find('.buttons span').text($(this).val()); }); });

preferences:
190.56 ms | 408 KiB | 260 Q