js初学者。帮帮忙看下代码。
<body>
<div class="logo1">aaaaa</div>
<div class="logo2">aaaaa</div>
<div class="logo3">aaaaa</div>
</body>
<script type="text/javascript">
var nodes = document.getElementsByTagName("div");
if (nodes)
{
for (var i = 0; i < nodes.length; i++) {
var o = nodes[i];
var li_class = o.className;
// alert("o");
switch ("li_class") {
case "logo1":
hcmy(logo1, "?hcmy_homepagelog=LOGO1")
case "logo2":
hcmy(logo2, "?hcmy_homepagelog=LOGO2")
case "logo3":
hcmy(logo3, "?hcmy_homepagelog=LOGO3")
break;
default:
}
}
}
function hcmy(li_class, li_href) {
alert("hcmy");
$(".+'li_class'").mousedown(function () {
hcclick(li_href);
});
}
function hcclick(param) {
alert("hcclick");
if (document.images) {
var rannumber = Math.round(Math.random() * 10000);
(new Image()).src = "http://log.info.hc360.com/click.htm" + param + "&rannumber=" + rannumber;
}
return true;
}
</script>
------解决方案--------------------具体问题是什么?
------解决方案--------------------switch 条件没执行到
------解决方案--------------------switch ("li_class") {
这里写错了吧!你这里应该是用变量,去掉双引号
这样写
switch (li_class) {
------解决方案--------------------这有点囧啊 基本语法都错了 直接说功能让打给你写个吧
------解决方案--------------------楼主把功能 需求发出来吧我们写
------解决方案--------------------JScript code
<script type="text/javascript">
var nodes = document.getElementsByTagName("div");
if (nodes)
{
for (var i = 0; i < nodes.length; i++) {
var o = nodes[i];
var li_class = o.className;
// alert("o");
switch ("li_class") {
case "logo1":
hcmy(logo1, "?hcmy_homepagelog=LOGO1");
break;
case "logo2":
hcmy(logo2, "?hcmy_homepagelog=LOGO2");
break;
case "logo3":
hcmy(logo3, "?hcmy_homepagelog=LOGO3");
break;
default:
break;
}
}
}
function hcmy(li_class, li_href) {
alert("hcmy");
$([color=#FF0000]"."+li_class[/color]).mousedown(function () {
hcclick(li_href);
});
}
function hcclick(param) {
alert("hcclick");
if (document.images) {
var rannumber = Math.round(Math.random() * 10000);
(new Image()).src = "http://log.info.hc360.com/click.htm" + param + "&rannumber=" + rannumber;
}
return true;
}
</script&g