Adsense in contents

텍스트박스 글자 클립보드로 복사하는 방법 1가지

텍스트박스 글자 클립보드로 복사하는 방법을 찾아보다가 챗GPT와 함께 만들어 봤습니다. 복사하기 버튼에 마우스 오버시 tooltips 까지 나옵니다. 아래 포스팅은 기록형으로 추후 참고하기 위해 작성되었습니다. 필요하신 분들은 사용하셔도 됩니다.

  • 질문에 답변을 해 드릴 수 없습니다.
텍스트박스 글자 클립보드로 복사하는 방법 1가지

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.tooltip {
  position: relative;
  display: inline-block;
}

.tooltip .tooltiptext {
  visibility: hidden;
  width: 140px;
  background-color: #555;
  color: #fff;
  text-align: center;
  border-radius: 6px;
  padding: 5px;
  position: absolute;
  z-index: 1;
  bottom: 150%;
  left: 50%;
  margin-left: -75px;
  opacity: 0;
  transition: opacity 0.3s;
}

.tooltip .tooltiptext::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: #555 transparent transparent transparent;
}

.tooltip:hover .tooltiptext {
  visibility: visible;
  opacity: 1;
}

.button {
  border: none;
  color: white;
  padding: 10px 10px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 13px;
  margin: 2px 2px;
  -webkit-transition-duration: 0.4s; /* Safari */
  transition-duration: 0.4s;
  cursor: pointer;
}

.button3 {
  background-color: white; 
  color: black; 
  width: 100px;
  border: 2px solid #f44336;
}

.button3:hover {
  background-color: #f44336;
  color: white;
}

</style>

<script>
function myFunction() {
  var copyText = document.getElementById("myInput");
  copyText.select();
  copyText.setSelectionRange(0, 99999);
  navigator.clipboard.writeText(copyText.value);
  
  var tooltip = document.getElementById("myTooltip");
  tooltip.innerHTML = "복사완료!<br> 붙여넣기하세요"
}

function outFunc() {
  var tooltip = document.getElementById("myTooltip");
  tooltip.innerHTML = "클릭! 복사됩니다";
}
</script>
</head>
<body>


<div style="width:100%; max-width:1200px; margin:30px auto;">

<div>
<textarea id="myInput" style="border:5px solid #ff6600;font-size:13px;height:60px;width: 300px;max-width:100%;padding:5px;">
단축 URL 링크 주소 줄이기
회원가입없이 무료로 긴 링크 주소를 짧게 줄여주는 서비스
https://url.kr
</textarea>
</div>

<div class="tooltip">
<button onclick="myFunction()" onmouseout="outFunc()" class="button button3">
  <span class="tooltiptext" id="myTooltip">클릭! 복사됩니다</span>
  복사하기
  </button>
</div>

</div>

</body>
</html>

Leave a Comment

함께보면 유용한 글


Robots.txt 몰랐던 부분

robots.txt 관련 글을 읽어보면 이해가 된다. 하지만 실제로 내가 원하는 방향으로 설정하려면 맞게 한 것인지 검증을 할 곳이 없이 애매할 때가 종종 있었습니다. 오늘은 제가 평상시 애매했던 부분을 알게 되어 ... Read more

간헐적 단식 다이어트 이런건가? 13일째 결과

간헐적 단식 들어는 봤나요? 오늘 이 다이어트 방식을 강제로 하게 되었네요. 퇴근 후 집에와서 밥을 먹으면 너무 늦어 저녁 해결 후 출발 하려고 했는데 그걸 놓쳤네요. 그래서 오늘은 저녁까지 스킵하게 ... Read more

판촉물제작 쇼핑몰 어디가 좋은가?

판촉물제작 생각 하시나요? 판촉물제작 쇼핑몰 찾고 있으신가요? 오늘 알아볼 내용은 기업홍보를 위해 필요한 판촉물 선정에 관한 유용한 팁 입니다. 홍보대상 선정 가장 먼저 어떤 대상을 상대로한 홍보물을 만들 것인가? 아니면 ... Read more

새로운 블로그 시작

2022년 2월 내 인생의 새로운 블로그를 시작 합니다. 이젠 더이상 헤메지 말고 이곳에 정착 할 수 있도록 해주세요