Adjusting jquery for WordPress

By default, jQuery runs in no conflict mode in WordPress. You have an anonymous function that passes the jQuery object so you can use it.

Your code will error on line two because it doesn’t know what $ is. Move the first three lines into the anonymous function to resolve this.

(function($){
var array = [];
var array1 = $('#input_8_3').val().split(',');
$("#input_8_3").val(array.join());

$('div.thumbn').click(function() {
    var text = $(this).attr("id").replace('img-act-','');
  var oldtext = $('#input_8_3').val();
    if ($(this).hasClass('chosen-img'))
  {

    $('#input_8_3').val(text+oldtext);      
    var index = array.indexOf(text);
    if (index !== -1)
    {
        array.splice(index, 1);
    }

    array1.push(text);
    $(this).removeClass('chosen-img');
  }
  else
  {
    array.push(text);
    var index = array1.indexOf(text);
    if (index !== -1)
    {
        array1.splice(index, 1);
    }
    $(this).addClass('chosen-img');
  }
  $("#input_8_3").val(array.join());
  $("#input_8_4").val(array1.join());
  console.log(array1);
});
})(jQuery);