0

Update: I have determined that IE9 recognizes the count and increases it, but I can't get it to change the text in the paragraph. I updated the code below and the js fiddle.

This isn't working in IE9 - does anyone know why? Or what I am doing wrong?I'm not quite sure why, it seems like a simple counter like this wouldn't be much trouble. I am able to test IE9 in Browserstack. Thanks in advance.

http://jsfiddle.net/sywx1ws7/4/

    <p id="mycount">NULL</p>
    <p class="correct-ans active-trigger">Click Counter</p>

    $(document).ready(function(){
    var count = 0;
    $('p#mycount').text(count);
    $( ".correct-ans.active-trigger" ).click(function() {
    alert(count);
    count += 1;
    console.log(count);


    if(count == 0){
    //do something
    $('p#mycount').text(0);
    }

    else if(count == 1) {
    //do something
    $('p#mycount').text(1);

    }

    else if(count == 2) {
    //do something
    $('p#mycount').text(2);
    }

    else if(count == 3) {
    //do something
    $('p#mycount').text(3);
    }

    else if(count == 4) {
    //do something
    $('p#mycount').text(4);
    }

    else if(count == 5) {
    //do something
    $('p#mycount').text(5);
    }


    else {

    }

    });
    });
seanx
  • 131
  • 3
  • 11
  • Well, what I am trying to achieve is a little more complex, I am hiding and showing various divs depending on what the counter number is at the end of a sequence of div panels (it's a mini 'quiz' that shows the corresponding div to the number of questions they get correct, which I am tracking with this counter). So to simplify, I broke it down to absolute essentials and am trying to simply change the number in the p id="mycount" in order to get it working. As I mentioned, it seems to work fine in IE10 and above and Chrome, FF, Safari etc. – seanx Mar 23 '15 at 18:08
  • Sorry, and to elaborate, in IE9, the number doesn't change, it doesn't appear to recognize the var count as changing - so I'm not sure how it needs to be coded differently for IE9, but something isn't jiving. – seanx Mar 23 '15 at 18:12
  • Updated the fiddle and code slightly - IE9 does increase the count, as evidenced by the change in each alert box, but it still is not able to alter the paragraph text. – seanx Mar 23 '15 at 18:34

1 Answers1

0

Looks like IE9 chokes on the console.log function unless you actually have the console open - so removing that line solved my problem (found the answer here on a unrelated IE9/jQuery post JQuery dialog (with button) not working in IE9).

Community
  • 1
  • 1
seanx
  • 131
  • 3
  • 11