문제 : 포탈의 검색창이 있다고 했을 때 이 안에 들어 갈 키워드를 순차적으로 보이게 하며, 해당 검색창을 클릭 했을 때 순차적으로 보이는 것을 멈추게 함.


<script>
var photos = ['1.jpg', '2.jpg', '3.jpg'];
var photo_index = 0;

$(function() {
    var timer = null;
    var input = document.getElementById('inputcode');

    function tick() {
        photo_index = (photo_index + 1) % photos.length;
        $('#inputcode').val(photos[photo_index]);
        start();
    };

    function start() {
        timer = setTimeout(tick, 1000);
    };

    function stop() {
        clearTimeout(timer);
    };

    $('#inputcode').bind("click", stop);

    start();
});
</script>
</head>
<body>
<input type="text" id="inputcode" >



---------------


프로타입은 구글링에서 찾았고, 여기서 더 수정했습니다.






jQuery로 작성한 스크립트가 에러를 뿜어 댑니다.

익스플로러에서는 null은 null이거나 개체가 없습니다.

파이어폭스에서는

$("head") is null
[Break On This Error]

$("head").append(cssHtml);


$("#아이디").size()) 라든가.


if($("#아이디").size() > 0){
.............
}

따로 파일을 생성해서 해당 스크립트만 했을 때는 정상이었습니다.

하나 하나 보니 의외에 곳이 문제였습니다.

기존에 작업되어 있던 prototype프레임웍과의 충돌 때문이었습니다.

jQuery를 사용할려면 prototype을 삭제해야 될 상황이었습니다.

함께 사용할려면 추가 해줘야 할 부분이 있습니다.

<script type="text/javascript">
 jQuery.noConflict();
</script>

jQuery로 된 js를 호출해서 사용한다면 해당 js파일에서 $대신에 jQuery를 교체해줘야 합니다.

에디터플러스에서 CTRL + H 신공!
이클립스에서 CTRL + F 신공!









 http://code.jquery.com/jquery-latest.min.js

<script  src="http://code.jquery.com/jquery-latest.min.js"></script>



위의 주소로 불러 오시면 항상 최신 버전을 사용하게 됩니다. ^^*




var plenary_name = $("input[name='plenary']:checked").val();
    if(plenary_name == "박 하선"){
        $("input[name='first_name']").val("하선");
        $("input[name='last_name']").val("박");
    }else if(plenary_name == "한 승연"){
        $("input[name='first_name']").val("승연");
        $("input[name='last_name']").val("한");
    }else if(plenary_name == "박 규리"){
        $("input[name='first_name']").val("규리");
        $("input[name='last_name']").val("박");
    }else if(plenary_name == "정 봉주"){
        $("input[name='first_name']").val("봉주");
        $("input[name='last_name']").val("정");
}

라디오 버튼 plenary이 체크되면 해당 라디오 버튼의 이름이 input box로 값이 넣어지는 jquery

+ Recent posts