here is my code (html)
<div id="navig" style="font-family: arial; font-size: 12px; font-weight: normal;">
<div id="navfirst"><a href="#" style="text-decoration: none;">First</a></div>
<div id="navnum"><a href="#" style="text-decoration: none;">1</a></div>
<div id="navnum"><a href="#" style="text-decoration: none;">2</a></div>
<div id="navnum"><a href="#" style="text-decoration: none;">3</a></div>
<div id="navnum"><a href="#" style="text-decoration: none;">4</a></div>
<div id="navnum"><a href="#" style="text-decoration: none;">5</a></div>
<div id="navlast"><a href="#" style="text-decoration: none;">Last</a></div>
$( document ).ready(function( ) {
$('div #navnum').click( function ( ) {
var divtext = $(this).text( ) ;
$( this ).css('background-color', '#f99');
$( this ).prevAll( ).css('background-color', '');
$( this ).nextAll( ).css('background-color', '');
$('#pgnum').html( '<p>clicked page number ' + divtext + '</p>' ).fadeIn( 100 );
});
});
works fine on firefox and chrome, but not in IE 8, how to make it work in IE
You shouldn’t be declaring the same
idon multiple elements in a HTML page.idis supposed to be unique to thedocument. Instead, try switching your divs that are usingnavnumfor anidto use them as aclass.classnames can be shared throughout your page. For example:Then for your click handler:
I made a jsFiddle you can test in IE.