is it possible to target the open dropdown toggle status and target its class and change a css definition?
I have a url check and want to change the background color of the dropdown toggle to a certain value, depending on its url.
The url grab function is working and i can manually change styles on different elements, but not the dropdown.
I inserted
$(“.sub-drop-toggle.w–open”).css(“background-color”, “#003d8f”);
But it does not change anything…
Sadly i cant provide a public share link but since its all about custom code that wouldnt help a lot…
well its more complicated. I have a “collection page template” which runs a script, that defines what element is called as a url and gives then a certain font or attribute to different elements because they need to have a different font as their corporate styling a.s.o.
But anyway …its working for
“.sub-drop-toggle” but not when i add the “w–open” class to it…it then just ignores the entry completely.
$(“.sub-drop-toggle”).css(“background-color”, “#003d8f”); = fine
$(“.sub-drop-toggle.w–open”).css(“background-color”, “#003d8f”); = not working
.sub-drop-toggle.w--open DOES NOT exist when the page is loaded, so you cannot set the style on an element that isn’t selected. The correct way is to override the style using CSS.
so there is no way of using it on my page cause i differentiate between three different style settings…
what about if i define the style within the css as a different class and then add or remove the corresponding class after page load?
Yea, fault was that the event was not created yet. So therefore I had to listen to the click event on the element itself and then add the correspondend class to it…
$("#sub-navi").click(function() {
var click = $(this).data('clicks');
if (click) {
$(this).removeClass("bg-col-1");
} else {
$(this).addClass("bg-col-1");
}
$(this).data('clicks', !click);
});
I m trying to style one page template that includes three different style settings with looking how the url ends, and then change the color correspondingly
1 collection page template =
www.xyz.com/client/clientA -> gets e.g. blue bg-color
www.xyz.com/client/clientB -> gets e.g. green bg-color
www.xyz.com/client/clientC -> gets e.g. yellow bg-color
script looks for last ending of the url =
if variable equals “clientA” then addClass “blue” to the dropdown toggle
and so on…