...

View Full Version : W3C Validation..



hol
05-26-2012, 01:12 PM
Hi, I know the problem but I don't know how to fix this. This is JQuery image slider and I used digit as my ID attribute but unfortunately, W3C invalid returns because:

Line 222, Column 18: value of attribute "id" invalid: "1" cannot start a name

In this case, I know that I cannot use digit as my id but the code makes me to use that id... please give me some advice on this thank you




<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script>
<script type="text/javascript">

function Slider(){

$(".slider #1").show("fade", 500);
$(".slider #1").delay(5500).hide("slide", {direction: 'left'}, 500);

var sc = $(".slider img").size();
var count = 2;

setInterval(function (){
$(".slider #"+count).show("slide", {direction: 'right'}, 500);
$(".slider #"+count).delay(5500).hide("slide", {direction: 'left'}, 500);

if(count == sc){
count = 1;
}else{
count = count + 1;
}
}, 6500);
}
</script>

<div class="slider">
<img id="1" src="images/slide0.png" border="0" alt="error" />
<img id="2" src="images/slide1.png" border="0" alt="error" />
</div>

abduraooft
05-26-2012, 01:46 PM
You could change the markup to something like

<img id="img_1" src="images/slide0.png" border="0" alt="error" />
<img id="img_2" src="images/slide1.png" border="0" alt="error" /> and then change the script to

function Slider(){

$(".slider #img_1").show("fade", 500);
$(".slider #img_1").delay(5500).hide("slide", {direction: 'left'}, 500);

var sc = $(".slider img").size();
var count = 2;

setInterval(function (){
$(".slider #img_"+count).show("slide", {direction: 'right'}, 500);
$(".slider #img_"+count).delay(5500).hide("slide", {direction: 'left'}, 500);

if(count == sc){
count = 1;
}else{
count = count + 1;
}
}, 6500);
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum