In my codepen I have two drop downs each with their own links that at currently have a relative url.
The basic structure of the list items look like this:
<ul class="which-way">
<li class="which-init">Unguided I-Day Return Trips</li>
<li data-value="value 2" class="cadja"><span class="value">beginners</span><span class="real">Darling Wine & Beer Trip</span></li>
<li data-value="value 3" class="cadja"><span class="value">mamre-werf-khwa-ttu-culture-day-by-which-way-trips</span><span class="real">Culture & Adventure Trip</span></li>
<li data-value="value 4" class="cadja"><span class="value">cape-west-coast-wildlife-fossil-trip</span><span class="real">Wildlife & Fossils Trip</span></li>
</ul>
With jquery I manage to get the text inside the span with the class value.
Now I want to add that value to a url when I click on it and the url should look like this for example:
Eg: http://www.google.com/beginners
When I click on the link after clicking on an li, the href does not change.
How can I change the href to the link that I want?
My JS currently looks like this:
$(document).ready(function(){
$("ul.which-way").on("click", function() {
$(this).find('li').toggleClass("open-list");
$(this).find('open-list').css("display", "block");
});
$("li.cadja").on("click", function(){
$($(this).parent().find('.which-init')[0]).html($(this).html());
handleDropdownOne();
});
});
window.handleDropdownOne = function() {
var dropOneValue = $($($('.drowpdown-one').find('.which-init')[0]).find('span.value')[0]).text();
console.log(dropOneValue);
};
handleDropdownOne();
$('a#trip').on("click", function(){
$(this).attr("href", "https://www.westcoastway.co.za/"+dropOneValue);
});
Please help