jquery 어떻게 둘 사이에 변수를 전달할 수 있습니까?

Mwordpress

jquery에서 둘 사이에 변수를 전달할 수 있습니까?

이 내 코드

    var gcolor;
    $('input[id^="cat-color"]').each(function() {
        function rgb2hex(rgb){
         rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
         return "#" +
          ("0" + parseInt(rgb[1],10).toString(16)).slice(-2) +
          ("0" + parseInt(rgb[2],10).toString(16)).slice(-2) +
          ("0" + parseInt(rgb[3],10).toString(16)).slice(-2);
        }
        var gcolor = rgb2hex($(this).css( "color" ));


    });
    $('a.wp-color-result').each(function() {
        //console.log(gcolor);
        $(this).css('background-color', gcolor);
    });

html 단 하나의 카테고리 14 개의 카테고리가 있습니다.

<div class="color-category-wrap">
    <div class="color-category-col-1"><span class="desc">Android</span>
    </div>
    <div class="color-category-col-2">
        <div class="title">Color : </div>
        <div class="wp-picker-container">
            <a class="wp-color-result" tabindex="0" title="Select Color" data-current="Current Color" style="background-color: rgb(238, 238, 34);"></a><span class="wp-picker-input-wrap"><input type="text" value="" placeholder="" name="mwp_newsbt[cat-color20][color]" id="cat-color20" class="color regular-text wp-color-picker" style="display: none; color: rgb(153, 153, 153);"><input type="button" class="button button-small wp-picker-clear hidden" value="Clear"></span>
            <div class="wp-picker-holder">
                <div class="iris-picker iris-mozilla iris-border" style="display: none; width: 255px; height: 202.125px; padding-bottom: 23.2209px;">
                    <div class="iris-picker-inner">
                        <div class="iris-square" style="width: 182.125px; height: 182.125px;"><a href="#" class="iris-square-value ui-draggable ui-draggable-handle" style="left: 30.3333px; top: 12.74px;"><span class="iris-square-handle ui-slider-handle"></span></a>
                            <div class="iris-square-inner iris-square-horiz" style="background-image: -moz-linear-gradient(left center , rgb(255, 35, 35), rgb(255, 145, 35), rgb(255, 255, 35), rgb(145, 255, 35), rgb(35, 255, 35), rgb(35, 255, 145), rgb(35, 255, 254), rgb(35, 145, 255), rgb(35, 35, 255), rgb(145, 35, 255), rgb(254, 35, 255), rgb(255, 35, 145), rgb(255, 35, 35));"></div>
                            <div class="iris-square-inner iris-square-vert" style="background-image: -moz-linear-gradient(center top , transparent, rgb(0, 0, 0));"></div>
                        </div>
                        <div class="iris-slider iris-strip" style="height: 205.346px; width: 28.2px; background-image: -moz-linear-gradient(center top , rgb(234, 234, 0), rgb(237, 237, 237));">
                            <div class="iris-slider-offset ui-slider ui-slider-vertical ui-widget ui-widget-content ui-corner-all"><span tabindex="0" class="ui-slider-handle ui-state-default ui-corner-all" style="bottom: 86%;"></span>
                            </div>
                        </div>
                    </div>
                    <div class="iris-palette-container">
                        <a tabindex="0" class="iris-palette" style="background-color: rgb(0, 0, 0); height: 19.5784px; width: 19.5784px; margin-left: 0px;"></a>
                        <a tabindex="0" class="iris-palette" style="background-color: rgb(255, 255, 255); height: 19.5784px; width: 19.5784px; margin-left: 3.6425px;"></a>
                        <a tabindex="0" class="iris-palette" style="background-color: rgb(221, 51, 51); height: 19.5784px; width: 19.5784px; margin-left: 3.6425px;"></a>
                        <a tabindex="0" class="iris-palette" style="background-color: rgb(221, 153, 51); height: 19.5784px; width: 19.5784px; margin-left: 3.6425px;"></a>
                        <a tabindex="0" class="iris-palette" style="background-color: rgb(238, 238, 34); height: 19.5784px; width: 19.5784px; margin-left: 3.6425px;"></a>
                        <a tabindex="0" class="iris-palette" style="background-color: rgb(129, 215, 66); height: 19.5784px; width: 19.5784px; margin-left: 3.6425px;"></a>
                        <a tabindex="0" class="iris-palette" style="background-color: rgb(30, 115, 190); height: 19.5784px; width: 19.5784px; margin-left: 3.6425px;"></a>
                        <a tabindex="0" class="iris-palette" style="background-color: rgb(130, 36, 227); height: 19.5784px; width: 19.5784px; margin-left: 3.6425px;"></a>
                    </div>
                </div>
            </div>
        </div>
        <div class="clear"></div>
        <div class="title">Background : </div>
        <div class="wp-picker-container">
            <a class="wp-color-result" tabindex="0" title="Select Color" data-current="Current Color"></a><span class="wp-picker-input-wrap"><input type="text" value="" placeholder="" name="mwp_newsbt[cat-color20][background]" id="cat-color20" class="color regular-text wp-color-picker" style="display: none; color: rgb(153, 153, 153);"><input type="button" class="button button-small hidden wp-picker-clear" value="Clear"></span>
            <div class="wp-picker-holder">
                <div class="iris-picker iris-mozilla iris-border" style="display: none; width: 255px; height: 202.125px; padding-bottom: 23.2209px;">
                    <div class="iris-picker-inner">
                        <div class="iris-square" style="width: 182.125px; height: 182.125px;"><a href="#" class="iris-square-value ui-draggable ui-draggable-handle" style="left: 0px; top: 182.133px;"><span class="iris-square-handle ui-slider-handle"></span></a>
                            <div class="iris-square-inner iris-square-horiz" style="background-image: -moz-linear-gradient(left center , rgb(255, 255, 255), rgb(255, 255, 255), rgb(255, 255, 255), rgb(255, 255, 255), rgb(255, 255, 255), rgb(255, 255, 255), rgb(255, 255, 255), rgb(255, 255, 255), rgb(255, 255, 255), rgb(255, 255, 255), rgb(255, 255, 255), rgb(255, 255, 255), rgb(255, 255, 255));"></div>
                            <div class="iris-square-inner iris-square-vert" style="background-image: -moz-linear-gradient(center top , transparent, rgb(0, 0, 0));"></div>
                        </div>
                        <div class="iris-slider iris-strip" style="height: 205.346px; width: 28.2px; background-image: -moz-linear-gradient(center top , rgb(0, 0, 0), rgb(0, 0, 0));">
                            <div class="iris-slider-offset ui-slider ui-slider-vertical ui-widget ui-widget-content ui-corner-all"><span tabindex="0" class="ui-slider-handle ui-state-default ui-corner-all" style="bottom: 0%;"></span>
                            </div>
                        </div>
                    </div>
                    <div class="iris-palette-container">
                        <a tabindex="0" class="iris-palette" style="background-color: rgb(0, 0, 0); height: 19.5784px; width: 19.5784px; margin-left: 0px;"></a>
                        <a tabindex="0" class="iris-palette" style="background-color: rgb(255, 255, 255); height: 19.5784px; width: 19.5784px; margin-left: 3.6425px;"></a>
                        <a tabindex="0" class="iris-palette" style="background-color: rgb(221, 51, 51); height: 19.5784px; width: 19.5784px; margin-left: 3.6425px;"></a>
                        <a tabindex="0" class="iris-palette" style="background-color: rgb(221, 153, 51); height: 19.5784px; width: 19.5784px; margin-left: 3.6425px;"></a>
                        <a tabindex="0" class="iris-palette" style="background-color: rgb(238, 238, 34); height: 19.5784px; width: 19.5784px; margin-left: 3.6425px;"></a>
                        <a tabindex="0" class="iris-palette" style="background-color: rgb(129, 215, 66); height: 19.5784px; width: 19.5784px; margin-left: 3.6425px;"></a>
                        <a tabindex="0" class="iris-palette" style="background-color: rgb(30, 115, 190); height: 19.5784px; width: 19.5784px; margin-left: 3.6425px;"></a>
                        <a tabindex="0" class="iris-palette" style="background-color: rgb(130, 36, 227); height: 19.5784px; width: 19.5784px; margin-left: 3.6425px;"></a>
                    </div>
                </div>
            </div>
        </div>
        <div class="clear"></div>
        <div class="title">Border : </div>
        <div class="wp-picker-container">
            <a class="wp-color-result" tabindex="0" title="Select Color" data-current="Current Color"></a><span class="wp-picker-input-wrap"><input type="text" value="" placeholder="" name="mwp_newsbt[cat-color20][border]" id="cat-color20" class="color regular-text wp-color-picker" style="display: none; color: rgb(153, 153, 153);"><input type="button" class="button button-small hidden wp-picker-clear" value="Clear"></span>
            <div class="wp-picker-holder">
                <div class="iris-picker iris-mozilla iris-border" style="display: none; width: 255px; height: 202.125px; padding-bottom: 23.2209px;">
                    <div class="iris-picker-inner">
                        <div class="iris-square" style="width: 182.125px; height: 182.125px;"><a href="#" class="iris-square-value ui-draggable ui-draggable-handle" style="left: 0px; top: 182.133px;"><span class="iris-square-handle ui-slider-handle"></span></a>
                            <div class="iris-square-inner iris-square-horiz" style="background-image: -moz-linear-gradient(left center , rgb(255, 255, 255), rgb(255, 255, 255), rgb(255, 255, 255), rgb(255, 255, 255), rgb(255, 255, 255), rgb(255, 255, 255), rgb(255, 255, 255), rgb(255, 255, 255), rgb(255, 255, 255), rgb(255, 255, 255), rgb(255, 255, 255), rgb(255, 255, 255), rgb(255, 255, 255));"></div>
                            <div class="iris-square-inner iris-square-vert" style="background-image: -moz-linear-gradient(center top , transparent, rgb(0, 0, 0));"></div>
                        </div>
                        <div class="iris-slider iris-strip" style="height: 205.346px; width: 28.2px; background-image: -moz-linear-gradient(center top , rgb(0, 0, 0), rgb(0, 0, 0));">
                            <div class="iris-slider-offset ui-slider ui-slider-vertical ui-widget ui-widget-content ui-corner-all"><span tabindex="0" class="ui-slider-handle ui-state-default ui-corner-all" style="bottom: 0%;"></span>
                            </div>
                        </div>
                    </div>
                    <div class="iris-palette-container">
                        <a tabindex="0" class="iris-palette" style="background-color: rgb(0, 0, 0); height: 19.5784px; width: 19.5784px; margin-left: 0px;"></a>
                        <a tabindex="0" class="iris-palette" style="background-color: rgb(255, 255, 255); height: 19.5784px; width: 19.5784px; margin-left: 3.6425px;"></a>
                        <a tabindex="0" class="iris-palette" style="background-color: rgb(221, 51, 51); height: 19.5784px; width: 19.5784px; margin-left: 3.6425px;"></a>
                        <a tabindex="0" class="iris-palette" style="background-color: rgb(221, 153, 51); height: 19.5784px; width: 19.5784px; margin-left: 3.6425px;"></a>
                        <a tabindex="0" class="iris-palette" style="background-color: rgb(238, 238, 34); height: 19.5784px; width: 19.5784px; margin-left: 3.6425px;"></a>
                        <a tabindex="0" class="iris-palette" style="background-color: rgb(129, 215, 66); height: 19.5784px; width: 19.5784px; margin-left: 3.6425px;"></a>
                        <a tabindex="0" class="iris-palette" style="background-color: rgb(30, 115, 190); height: 19.5784px; width: 19.5784px; margin-left: 3.6425px;"></a>
                        <a tabindex="0" class="iris-palette" style="background-color: rgb(130, 36, 227); height: 19.5784px; width: 19.5784px; margin-left: 3.6425px;"></a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

html http://pastebin.com/XSAw9bY5

gcolor에 대해 정의되지 않은 콘솔 로그에 표시됩니다.

변경 사항 (ajax)을 저장할 때 colorpicker 문제

색상을 선택하고 변경 사항을 저장하는 경우 http://img11.hostingpics.net/pics/159977categorycolor2.png

Barmar

그러면 a.wp-color-result요소와 동일한 카테고리 에있는 요소 의 색상이 설정됩니다 cat-color.

function rgb2hex(rgb){
    rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
    return "#" +
        ("0" + parseInt(rgb[1],10).toString(16)).slice(-2) +
        ("0" + parseInt(rgb[2],10).toString(16)).slice(-2) +
        ("0" + parseInt(rgb[3],10).toString(16)).slice(-2);
}
$('input[id^="cat-color"]').each(function() {
    var gcolor = rgb2hex($(this).css( "color" ));
    $(this).closest(".color-category-wrap").find('a.wp-color-result').css('background-color', gcolor);
});

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

jquery 어떻게 둘 사이에 변수를 전달할 수 있습니까?

분류에서Dev

둘 이상의 클래스 개체를 WCF REST API에 어떻게 전달할 수 있습니까?

분류에서Dev

jquery에서 PHP로 쿠키를 어떻게 전달할 수 있습니까?

분류에서Dev

jQuery Ajax 호출을 통해 양식 데이터와 내 변수를 어떻게 전달할 수 있습니까?

분류에서Dev

js 변수를 PHP 변수에 어떻게 전달할 수 있습니까?

분류에서Dev

jquery 값을 PHP 함수에 어떻게 전달할 수 있습니까?

분류에서Dev

linearSearch 함수에서 변수 i를 어떻게 전달할 수 있습니까?

분류에서Dev

Jquery Selector에서 C # ViewBag 변수를 어떻게 사용할 수 있습니까?

분류에서Dev

PHP 변수를 JavaScript에 어떻게 전달할 수 있습니까?

분류에서Dev

Vuex : getter에 변수를 어떻게 전달할 수 있습니까?

분류에서Dev

sed에 매개 변수를 어떻게 전달할 수 있습니까?

분류에서Dev

Zend에서 어떻게 변수를 전달할 수 있습니까?

분류에서Dev

phalconphp의 메인 뷰에 변수를 어떻게 전달할 수 있습니까?

분류에서Dev

nixos buildFHSUserEnv에 환경 변수를 어떻게 전달할 수 있습니까?

분류에서Dev

해석 된 파일에 변수를 어떻게 전달할 수 있습니까?

분류에서Dev

os.system에서 변수를 어떻게 전달할 수 있습니까?

분류에서Dev

imacros에서 javascript로 변수를 어떻게 전달할 수 있습니까?

분류에서Dev

jQuery .html ()을 사용하여 변수와 일부 HTML을 어떻게 전달할 수 있습니까?

분류에서Dev

jQuery 변수에서 가져온 값을 PHP로 어떻게 전달할 수 있습니까?

분류에서Dev

데이터를 어떻게 전달할 수 있습니까?

분류에서Dev

어떻게 jquery에서 데이터를 별도로 전달할 수 있습니까?

분류에서Dev

Jquery 플러그인에서 옵션으로 전달 된 함수를 어떻게 실행할 수 있습니까?

분류에서Dev

Electron에서 jQuery를 어떻게 사용할 수 있습니까?

분류에서Dev

jquery에서 coffeescript를 어떻게 사용할 수 있습니까?

분류에서Dev

Excel VBA에서 두 구독자 사이의 변수를 어떻게 전달할 수 있습니까?

분류에서Dev

파이썬 : 문자열 이름 만있는 함수에 변수를 어떻게 전달할 수 있습니까?

분류에서Dev

이 is_same 함수에 유형이나 변수를 어떻게 전달할 수 있습니까?

분류에서Dev

타이머 객체를 함수에 어떻게 전달할 수 있습니까?

분류에서Dev

jquery 슬라이더에서 django 백엔드에 두 값을 어떻게 전달할 수 있습니까?

Related 관련 기사

  1. 1

    jquery 어떻게 둘 사이에 변수를 전달할 수 있습니까?

  2. 2

    둘 이상의 클래스 개체를 WCF REST API에 어떻게 전달할 수 있습니까?

  3. 3

    jquery에서 PHP로 쿠키를 어떻게 전달할 수 있습니까?

  4. 4

    jQuery Ajax 호출을 통해 양식 데이터와 내 변수를 어떻게 전달할 수 있습니까?

  5. 5

    js 변수를 PHP 변수에 어떻게 전달할 수 있습니까?

  6. 6

    jquery 값을 PHP 함수에 어떻게 전달할 수 있습니까?

  7. 7

    linearSearch 함수에서 변수 i를 어떻게 전달할 수 있습니까?

  8. 8

    Jquery Selector에서 C # ViewBag 변수를 어떻게 사용할 수 있습니까?

  9. 9

    PHP 변수를 JavaScript에 어떻게 전달할 수 있습니까?

  10. 10

    Vuex : getter에 변수를 어떻게 전달할 수 있습니까?

  11. 11

    sed에 매개 변수를 어떻게 전달할 수 있습니까?

  12. 12

    Zend에서 어떻게 변수를 전달할 수 있습니까?

  13. 13

    phalconphp의 메인 뷰에 변수를 어떻게 전달할 수 있습니까?

  14. 14

    nixos buildFHSUserEnv에 환경 변수를 어떻게 전달할 수 있습니까?

  15. 15

    해석 된 파일에 변수를 어떻게 전달할 수 있습니까?

  16. 16

    os.system에서 변수를 어떻게 전달할 수 있습니까?

  17. 17

    imacros에서 javascript로 변수를 어떻게 전달할 수 있습니까?

  18. 18

    jQuery .html ()을 사용하여 변수와 일부 HTML을 어떻게 전달할 수 있습니까?

  19. 19

    jQuery 변수에서 가져온 값을 PHP로 어떻게 전달할 수 있습니까?

  20. 20

    데이터를 어떻게 전달할 수 있습니까?

  21. 21

    어떻게 jquery에서 데이터를 별도로 전달할 수 있습니까?

  22. 22

    Jquery 플러그인에서 옵션으로 전달 된 함수를 어떻게 실행할 수 있습니까?

  23. 23

    Electron에서 jQuery를 어떻게 사용할 수 있습니까?

  24. 24

    jquery에서 coffeescript를 어떻게 사용할 수 있습니까?

  25. 25

    Excel VBA에서 두 구독자 사이의 변수를 어떻게 전달할 수 있습니까?

  26. 26

    파이썬 : 문자열 이름 만있는 함수에 변수를 어떻게 전달할 수 있습니까?

  27. 27

    이 is_same 함수에 유형이나 변수를 어떻게 전달할 수 있습니까?

  28. 28

    타이머 객체를 함수에 어떻게 전달할 수 있습니까?

  29. 29

    jquery 슬라이더에서 django 백엔드에 두 값을 어떻게 전달할 수 있습니까?

뜨겁다태그

보관