라디오 버튼 선택으로 html의 backgroundImage를 변경하고 싶습니다. 모든 라디오 버튼마다 다른 이미지가 있습니다.라디오 버튼으로 배경 이미지 변경
<input name="BG" id="wood" type="radio" value="" class="bgCollection" />
<label for="radio">Wood</label>
<input name="BG" id="steel" type="radio" class="bgCollection"/>
<label for="radio">Steel</label>
<input name="BG" id="metal" type="radio" value="" class="bgCollection"/>
<label for="radio">Black metal</label>
JQuery와 : 내가 좋아하는 그것을 시도
$(document).ready(function(){
$(".bgCollection").change(
function()
{
if($("input#wood").attr("checked"))
{$("html").css('backgroundImage','url(../images/wood.jpg)');}
if($("input#steel").attr("checked")
{$("html").css('backgroundImage','url(../images/BG-steel.jpg)');}
if($("input#metal").attr("checked"))
{$("html").css('backgroundImage','url(images/blackMetal.jpg)');}
});
});
그러나 배경이 변경되지 이런 식으로.
jsfiddle을 사용하여 실행 가능한 코드를 게시하면 좋을 것입니다. – uuidcode