Remove a wild “-” dash from active class anchor tag

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Remove a wild “-” dash from active class anchor tag



I have used this https://jsfiddle.net/u9d1ewsh/ to add pagination in my table, which works fine. The issue is a wild "-" dash appearing on the active page number (please see pic below). I have checked the same using Developer tools, its not a character and it happens to be only for active class. What do I do to remove it ?


$(document).ready(function ()
$('#tblAH1').after('<div id="pager" style="" ></div>');
var rowsShown = 5;
var rowsTotal = $('#tblAH1 tbody tr').length;
var numPages = rowsTotal / rowsShown;
for (i = 0; i < numPages; i++)
var pageNum = i + 1;
$('#pager').append('<a href="#" rel="' + i + '">' + pageNum + '</a> ');

$('#tblAH1 tbody tr').hide();
$('#tblAH1 tbody tr').slice(0, rowsShown).show();
$('#pager a:first').addClass('active');
$('#pager a').bind('click', function ()

$('#pager a').removeClass('active');
$(this).addClass('active');
var currPage = $(this).attr('rel');
var startItem = currPage * rowsShown;
var endItem = startItem + rowsShown;
$('#tblAH1 tbody tr').css('opacity', '0.0').hide().slice(startItem, endItem).
css('display', 'table-row').animate( opacity: 1 , 300);
event.preventDefault();
);
);


#pager
display: inline-block;
align-items: center;


#pager a
color: black;
float: left;
padding: 4px 8px;
text-decoration: none;


#pager a.active
background-color: #fb9a55;
padding: 4px 8px;
color: white;


#pager a:hover:not(.active)
background-color: #ddd;



enter image description here





Is it not happening in the fiddle?
– void
Aug 13 at 8:46





surprisingly No. For my code it happening in both IE and chrome.
– Sak
Aug 13 at 8:47





Could be because you have not added any styles in fiddle? Can you add the CSS in the fiddle?
– void
Aug 13 at 8:47





You've an extra - somewhere in the script...
– Zakaria Acharki
Aug 13 at 8:47


-





@ZakariaAcharki I checked the script (pasted in question) .. there is no extra - . Not even in developer tools.
– Sak
Aug 13 at 8:48




2 Answers
2



Add the following css, the line may be generated by a pseudo selector


.active:before,.active:after
content:"";
display:none;



if you have other libraries like bootstrap its possible that the active class is styled with that line, ether you override the css or you change your class name


active





This will not solve the main problem, this is a workaround hack...
– Zakaria Acharki
Aug 13 at 8:50





@ZakariaAcharki why do you think its a "workaround hack"? how do you know this will not solve the problem?
– madalinivascu
Aug 13 at 8:52





Since you don't know from where the extra dash comes.
– Zakaria Acharki
Aug 13 at 8:53





@ZakariaAcharki But does it fix your problem? If so, you know what to look for.
– Douwe de Haan
Aug 13 at 8:55





my intuition tells me that the dash comes from the pseudo selector because he says it doesn't appear in the html, so it should be ether css or js, we can rule out the js (we have it) so css remains
– madalinivascu
Aug 13 at 8:57



Try this:


$('#pager').append('<a href="#" rel="' + i + '">' + pageNum.replace('-','') + '</a> ');





This will not solve the main problem, this is a workaround hack...
– Zakaria Acharki
Aug 13 at 8:52





Cant replace it because a real "-" isn't there.
– Sak
Aug 13 at 8:59






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Creating a leaderboard in HTML/JS