텍스트 상자 대신 이미지가 있어야합니다. 인터넷 검색 :이 사이트를 발견 : http://ryanfait.com/resources/custom-checkboxes-and-radio-buttons/ 그리고 정말 어떻게 보이는지. 하지만 필요한 확인란이 facebook과 twiter에서 '공유도'이므로 체크 상자에 두 개의 서로 다른 이미지가 필요합니다.여러 이미지가있는 사용자 정의 확인란
.checkboxfb {
width: 23px; height: 23px; padding: 0 5px 0 0;
background: url(images/files/ico_facebook_mult_sml2.png) no-repeat;
display: block; clear: left; float: left;}
.checkboxtw {
width: 23px; height: 22px; padding: 0 5px 0 0;
background: url(images/files/twitter_logo_mult_sml.png) no-repeat;
display: block; clear: left; float: left;}
내가 HTML에서 서로간에 클래스를 차별화 : 내가 먼저 CSS를 수정하여 그렇게 할 수
<form method="post" action=".">
<input type="checkbox" name="fb" class="styledfb" />FB <br /><br />
<input type="checkbox" name="tw" class="styledtw" />TW </form>
그리고 복제 스크립트, FBcheckbox.js :
document.write('<style type="text/css">input.styled**fb** { display: none; } select.styled**fb** { position: relative; width: ' + selectWidth + 'px; opacity: 0; filter: alpha(opacity=0); z-index: 5; } .disabled { opacity: 0.5; filter: alpha(opacity=50); }</style>');
var Custom = {
inita: function() {
var inputs = document.getElementsByTagName("input"), span = Array(), textnode, option, active;
for(a = 0; a < inputs.length; a++) {
if((inputs[a].type == "checkbox" || inputs[a].type == "radio") && inputs[a].className == "styledfb") {
span[a] = document.createElement("span");
span[a].className = inputs[a].type + "**fb**";
물론, 다른 js 파일은 'fb'대신 'tw'를 가지며 TWcheckbox.js라고합니다. (여기서 전체 js를 볼 수 있습니다 : http://pasionesargentas.webatu.com/js/checkbox/FBcheckbox.js 및 http://pasionesargentas.webatu.com/js/checkbox/TWcheckbox.js). 헤더에서
나는 두 파일을 호출 오전 :
<script type="text/javascript" src="js/checkbox/FBcheckbox.js"></script> <script type="text/javascript" src="js/checkbox/TWcheckbox.js"></script>
이제 재미있는 것은 그 중 하나가 한 번에 작동합니다. 머리말에서 두 번째로 전화를 걸면됩니다. 테스트 파일은 http://pasionesargentas.webatu.com/test1.php
감사합니다. 하지만 여전히 문제가 있습니다. 'window.onload = Custom.init;'의 구문은 무엇입니까? 그래서 그것은 inita와 initb 둘 다 발생시킨다. – cbarg
저는 Customa와 Customb를 변수와 동일한 결과로 실험하고 있습니다 : 두 번째가 나타납니다! – cbarg
안녕하세요, @cbarg, 죄송합니다. window.onload를 두 번 할당하는 것과 동일한 문제가 있습니다. 가장 최근에 실행 한 window.onload 할당은 이전 값을 덮어 씁니다. 그 주위에 다음과 같은 문법을 사용하는 것이 좋습니다 : if (window.addEventListener) {window.addEventListener ("load", Customa.inita, false); } else if (window.attachEvent) {window.attachEvent ("onload", Customa.inita); }'- 두 번째 JS 파일의 경우 Customa.inita를 Customb.initb로 전환합니다. – dentaku