-1

I have this html code:

    <div class="staff_options dep_0" onclick="javascript: selectDepartamento(0, 'black')">
        <hr class="hr_staff dep_0" style="width:50px;">ShBarcelona<hr class="hr_staff dep_0" style="width:50px;">
    </div>
    <div class="staff_options dep_1" onclick="javascript: selectDepartamento(1, 'rgb(165,33,33)')">
        <hr class="hr_staff dep_1" style="width:65px;">Dirección<hr class="hr_staff dep_1" style="width:65px;">
    </div>
    <div class="staff_options dep_2" onclick="javascript: selectDepartamento(2, 'rgb(42, 54, 199)')">
        <hr class="hr_staff dep_2" style="width:47px;">Administración<hr class="hr_staff dep_2" style="width:47px;">
    </div>

and the function selectDepartamento only does this:

if (id != 0){
    $('.empleado_imagen').css("background-size", '0px');
    $('.dep_'+id).css("background-size", '125px');
}else{
    $('.empleado_imagen').css("background-size", '125px');
}

$('.staff_options').css('color', 'black');
$('.staff_options').css('font-weight', 'normal');
$('.staff_options.dep_'+id).css("color", "'"+color+"'");
$('.staff_options.dep_'+id).css("font-weight", "bold");

if !($.browser.msie){
    $('.hr_staff').css('display', 'none');      
    $('.hr_staff.dep_'+id).css("border-color", "'"+color+"'");
    $('.hr_staff.dep_'+id).css('display', 'inline-block');
}

with Google Chrome and Mozilla Firefox this works well but IE only detect onclick event when I'm using element inspector.

I don't understand because this not works. Thanks.

  • What version of IE you are using? – Shaikh Farooque Apr 29 '14 at 09:26
  • 1
    `but IE only detect onclick event when I'm using element inspector.` Sounds like you have included `console.log()` in your code. – Praveen Apr 29 '14 at 09:26
  • What version of jQuery you are using? Please make jsFiddle. – Flash Thunder Apr 29 '14 at 09:26
  • Note that `onclick` and such are not URLs, you don't use the `javascript:` pseudo-protocol with them. (When you do, the only reason it doesn't cause a syntax error is that it looks like a code label.) – T.J. Crowder Apr 29 '14 at 09:29
  • ALso note that the line `$('.staff_options.dep_'+id).css("color", "'"+color+"'");` is almost certainly wrong. I'm assuming `color` is the second argument to your function (why have you left the function declaration out of the question?!). So if you pass in the string `black`, that line evaluates to `$('.staff_options.dep_'+id).css("color", "'black'");` Don't use the quotes, you just want `$('.staff_options.dep_'+id).css("color", color);` – T.J. Crowder Apr 29 '14 at 09:32

1 Answers1

0

...but IE only detect onclick event when I'm using element inspector...

As Praveen said in a comment, that sounds like you've used the console object somewhere you haven't shown. In IE, the console object only exists when the dev tools are open.

Community
  • 1
  • 1
T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875