Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Color Selector and adding a class to multiple variables

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #157789
    AlterEagle
    Participant

    I’m hoping someone here can help me with this color selector. After a couple of days I finally got this one https://github.com/recurser/jquery-simple-color to work with this:

    --------BASIC HTML---------
    <A class=test href="#">this is a test</A>
    
    <INPUT class=color name=NormalLinkColor value=#262626 />
    <INPUT class=color name=BorderColor value=#767570 />
    <INPUT class=color name=HoverBorderColor value=#767570 />
    <INPUT class=color name=HoverLinkColor value=#ffbf28 />
    
    <INPUT name=confirm value=Confirm type=button />
    
    --------- jQuery --------------
    $("input[name='confirm']").click(function() {
    var nlc = $("input[name='NormalLinkColor']").val();
    var nbc = $("input[name='BorderColor']").val();
    var hbc = $("input[name='HoverBorderColor']").val();
    var hlc = $("input[name='HoverLinkColor']").val();
    var div = $("<div />", {
        html: '­<style>a.test:link{color:' + (nlc) + ';border:' + (nbs) + ' solid ' + (nbc) + '}a.test:hover{color:' + (hlc) + ';border:' + (nbs) + ' solid ' + (hbc) + '}</style>'
      }).appendTo("body");  
    });
    

    But even after I customized it’s color selection it just wasn’t what was needed for what I’m doing on a project so I’ve switched to this one https://github.com/evoluteur/colorpicker

    I can’t figure out how to get the .colorpicker() into the variables so you can click on them for the values for this one? var nlc = $("input[name='NormalLinkColor']").val(); Got it on a single input like this.

    <div id="divbgcolor1"></div>
    
    <INPUT id=bg1 class=genput value=#000000>
    
    $('#bg1').colorpicker()
    .on('change.color', function(evt, color){
    $("#divbgcolor1").css("background-color",$(this).val());
    });
    

    It’s driving me nuts, I know it has to be something simple I’m missing?

    #157798
    sadunaresh
    Participant

    here you go…

    hope this is what you expected… :)

    #157810
    AlterEagle
    Participant

    I appreciate the reply but that’s the one I have working.

    It was something dumb as usual, I just had to invoke the new one on the input with an id & some jQuery instead of trying to do it in the variables.

    Sometimes you can stare at these too dang long. It actually helped to get it out, to think about it a bit, so thanks.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.