Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Jquery checkbox and tag creation not working in IE8

Posted on 2014-02-25
Medium Priority
Last Modified: 2014-02-25
Hi Experts,

I have got this code working in all browsers inc ie9 - except for ie8.

Its been driving me mad for over 3 hours now so thought I'd get an extra set of eyes on it.

Please Help


if ($('#selected-breeds').children(".tag").length === 0) {

    $('#available-breeds :checkbox').click(function () {
        function selectedBreedFade() {
            if (!$('#selected-breeds').find('a').length) {
            } else {


        if ($(this).is(':checked')) {
            var checkedBreed = $(this).parent().next('td').find('label').text();
            $('<a class="tag">&times; <span>'+checkedBreed+'</span>').appendTo('#selected-breeds');
        } else {
            var uncheckedBreed = $(this).parent().next('td').find('label').text();
            $('#selected-breeds').find('.tag span:contains(' + uncheckedBreed + ')').parent().fadeOut('fast').remove();

        $('#selected-breeds .tag').click(function () {
            var removedBreed = $(this).find('span').text();
            $('#available-breeds').find('label:contains(' + removedBreed + ')').parent().prev('td').find(':checkbox').attr('checked', false);

        $('#button-reset-search').click(function () {
            $('#available-breeds :checkbox').prop('checked', false);


Open in new window


<table id="available-breeds">
                                   <tr><td><input type="checkbox" name="Breed" value="AA" /></td><td><label>Aberdeen Angus (AA)</label></td></tr>
                   <tr><td><input type="checkbox" name="Breed" value="AAX" /></td><td><label>Aberdeen Angus Cross (AAX)</label></td></tr>
                   <tr><td><input type="checkbox" name="Breed" value="AR" /></td><td><label>Angler Rotvieh (AR)</label></td></tr>
                   <tr><td><input type="checkbox" name="Breed" value="ARX" /></td><td><label>Angler Rotvieh Cross (ARX)</label></td></tr>
                   <tr><td><input type="checkbox" name="Breed" value="AN" /></td><td><label>Ankole (AN)</label></td></tr>
                   <tr><td><input type="checkbox" name="Breed" value="AM" /></td><td><label>Armoricaine (AM)</label></td></tr>
                   <tr><td><input type="checkbox" name="Breed" value="AMX" /></td><td><label>Armoricaine Cross (AMX)</label></td></tr>
                   <tr><td><input type="checkbox" name="Breed" value="AU" /></td><td><label>Aubrac (AU)</label></td></tr>
                   <tr><td><input type="checkbox" name="Breed" value="AUX" /></td><td><label>Aubrac Cross (AUX)</label></td></tr>
                   <tr><td><input type="checkbox" name="Breed" value="ALL" /></td><td><label>Australian Lowline (ALL)</label></td></tr>
                   <tr><td><input type="checkbox" name="Breed" value="AY" /></td><td><label>Ayrshire (AY)</label></td></tr>
                   <tr><td><input type="checkbox" name="Breed" value="AYX" /></td><td><label>Ayrshire Cross (AYX)</label></td></tr>

<div id="selected-breeds" class="form-row">
  <span class="form-title">Selected Breeds</span>
  <!-- Selected Breeds -->

Open in new window

Many thanks in advance
Question by:mcluff
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 59

Accepted Solution

Julian Hansen earned 2000 total points
ID: 39885363
It seems to be choking on the line where you add the <a> to selected-breeds.

Try this instead
        // ... to line 18
        if ($(this).is(':checked')) {
            var checkedBreed = $(this).parent().next('td').find('label').text();
            // USE THIS LINE
            $('#selected-breeds').append($('<a/>').addClass('tag').html('&times; <span>'+checkedBreed+'</span>'));
             // INSTEAD OF THIS ONE
             // $('<a class="tag">&times; <span>'+checkedBreed+'</span>').appendTo('#selected-breeds');
        } else {
            var uncheckedBreed = $(this).parent().next('td').find('label').text();
            $('#selected-breeds').find('.tag span:contains(' + uncheckedBreed + ')').parent().fadeOut('fast').remove();
        // .....

Open in new window

LVL 53

Expert Comment

by:Scott Fell, EE MVE
ID: 39885369
Are you using jquery 2.x?  That will not support ie8.  You have to use 1.1x

Author Comment

ID: 39885448
I'm using 1.10

The rest of my jquery works - its just this part.

Author Closing Comment

ID: 39885451
Many thanks
LVL 59

Expert Comment

by:Julian Hansen
ID: 39885464
You are welcome - thanks for the points.

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
The viewer will learn how to dynamically set the form action using jQuery.

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question