Basically, i have a menu like this:
<a class="tab-feed-filter-switch active bound" href="sample.com/ALL" data-target="#filter-fb">FACEBOOK</a>
<a class="tab-feed-filter-switch active bound" href="sample.com/fb" data-target="#filter-all">All</a>
<a class="tab-feed-filter-switch active bound" href="sample.com/ig" data-target="#filter-ig">ig</a>
And i wish to append something like "?startDate=20160121&endDate=20160212"
:
$("#appendHerf").click(function(){
var href = $('a.tab-feed-filter-switch').attr('href') + '?startDate=20160121&endDate=20160212';
$('a.tab-feed-filter-switch').attr('href', href);
});
The result of the methods above which is incorrect:
<a class="tab-feed-filter-switch active bound" href="sample.com/ALLl&?startDate=20160121&endDate=20160212" data-target="#filter-fb">FACEBOOK</a>
<a class="tab-feed-filter-switch active bound" href="sample.com/ALL&?startDate=20160121&endDate=20160212" data-target="#filter-all">All</a>
<a class="tab-feed-filter-switch active bound" href="sample.com/ALL&?startDate=20160121&endDate=20160212 data-target="#filter-ig">ig</a>
My exception is as below:
<a class="tab-feed-filter-switch active bound" href="sample.com/ALL&?startDate=20160121&endDate=20160212" data-target="#filter-fb">FACEBOOK</a>
<a class="tab-feed-filter-switch active bound" href="sample.com/FB&?startDate=20160121&endDate=20160212" data-target="#filter-all">All</a>
<a class="tab-feed-filter-switch active bound" href="sample.com/ig&?startDate=20160121&endDate=20160212 data-target="#filter-ig">ig</a>
The above method is working fine at my other program but because the plugin generate same class for all of them, it replace all the herf into a single duplicate herf , which i can't change it in html.
I am thinking about to get the date-target element and add new class to control it but i am not sure if this can work and maybe there's some better alternative to solve this issue.
This is my last question but it doesn't seem can solve my problem :Append new path in all the a href URL
There's only one button, when i click, append startDate&endDate in every herf we got. so the result should like /fb/startDate&endDate , /All/startDate&endDate but now it's like when i click on the button every href replace to /All/startDate&endDate.