0

The Onepage-scroll plugin.

In the css files that come with the plugin the pagination has been styled by default. I would like to change the background- and border-color to match every section/page in my project.

Every section has a different background-color and font-color. Im trying to match the pagination to each font color.

This is the code i wrote. It checks if the plugin added the class 'active' to the 'body ul li a' element, wich the plugin adds automaticaly. Then i get the 'href' of this element and use it to store the css 'color' value in a variable. Now i grab the ".onepage-pagination li a:before" elements, wich come out of the onepage css file. And then i add my own css background and color values to all these elements.

The problem seems to be that the plugin crashes when i try to change one of it's defaults.

       if ($("body ul li a").hasClass('active')) {
            var link_href = $(this).attr('href');
            var color = $(link_href).css('color');
            $(".onepage-pagination li a:before").css({
                "background": color,
                "border": '1px solid' + color;
            });
        };

Where did i go wrong?

$("body ul li a").data() - returns 'object {index: 1}' in console

Would it be possible to use this data attribute in my own css to add style?

j08691
  • 204,283
  • 31
  • 260
  • 272
Kenneth
  • 13
  • 1
  • 6
  • `$(this).attr('href');` wont return a DOM element but the value of the href attribute. That said, you can't do `$.css` on a string value, there is no meaning. Also, consider to insert a blank space just after the `solid` word, otherwise it would try to apply: `'border': '1px solid#ff6600'` for example. – Fabiano Araujo Mar 20 '15 at 00:29
  • @Fabiano Araujo. $(this).attr('href'); returns "#1" in the console. – Kenneth Mar 20 '15 at 00:42
  • $(".onepage-pagination li a::before").css('border', '1px solid red !important'); ------ allsow doesn't work ? – Kenneth Mar 20 '15 at 01:07
  • $("body ul li a").data() returns 'object {index: 1}' in console. – Kenneth Mar 20 '15 at 01:31

0 Answers0