안될이유가 없는데 안돼서요 ㅜㅜ
<script>
for(var i=0; i<10 ; i++){
$(document).on("mouseover", "#wr_57_"+i, function(){
// what you want to happen when mouseover and mouseout
$("#wr_58_"+i).focus();
var wr_57 = $(this).val();
$("#wr_58_"+i).attr("value", wr_57);
});
$(document).on('mouseout', "#wr_58_"+i, function(){
// what you want to happen when mouseover and mouseout
var wr_58 = $(this).val();
$("#wr_57_"+i).attr("value", wr_58);
});
}
</script>
|
답변 2개 / 댓글 2개
채택된 답변
+20 포인트
어떤걸 할려고 하는데 무엇이 어떻게 안되나요
코드도 분석해야 하는데 왜 저렇게 물었는지 질문조차 분석해야 한다면 좋은 답을 얻기가 힘이 듭니다
Copy
$(document).on("mouseover","[id^='wr_57_']",function() {
var target_id = $(this).attr('id').replace('wr_57','wr_58');
$('#'+target_id).val($(this).val()).focus();
});
$(document).on("mouseout","[id^='wr_58_']",function() {
var target_id = $(this).attr('id').replace('wr_58','wr_57');
$('#'+target_id).val($(this).val());
});
답변을 작성하려면 로그인이 필요합니다.
펑션이나 인덱스없이 그냥 위에 코드로만 하면서
오타나 뭐 구문에 틀린게 있나 하고
삽질했습니다. ㅜㅜ
function larger(obj){
var index = $("tr[class='tr']").size();
//console.log(index);
for(var k=0; k<index ; k++){
$(document).on("mouseover", "#wr_57_"+index, function(){
// what you want to happen when mouseover and mouseout
// occurs on elements that match '.dosomething'
console.log('이거', k);
$("#wr_58_"+index).focus();
var wr_57 = $(this).val();
$("#wr_58_"+index).attr("value", wr_57);
});