3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
$(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()); }); });