日期:2014-05-16  浏览次数:20340 次

求 document.getElementById("brandul").getElementsByTagName("li") 里面的具体值,请看代码更清楚
JScript code
function pubfunction()
                    {
                        var liarr = document.getElementById("brandul").getElementsByTagName("li");
                        for(var i=0;i<liarr.length;i++)
                        {
                            liarr[i].onclick=function()
                            {
                                document.getElementById("brandstyle").style.display="none";
                                document.getElementById("ibay_search_1").innerHTML = this.getAttribute("rel");
                            }
                        }
                            
                    }


HTML code

<span id="ibay_search_1">-</span>
<ul id="brandul">
                        <li><a href="javascript:void(0)" rel="Aprilia" id="brand1" onclick="changemodel('Aprilia');pubfunction()">Aprilia</a></li>
                        <li><a href="javascript:void(0)" rel="BMW" id="brand2" onclick="changemodel('BMW');pubfunction()">BMW</a></li>
                        <li><a href="javascript:void(0)" id="brand3" onclick="changemodel('BUELL');pubfunction()">BUELL</a></li>
                        <li><a href="javascript:void(0)" id="brand4" onclick="changemodel('Ducati');pubfunction()">Ducati</a></li>
                        <li><a href="javascript:void(0)" id="brand5" onclick="changemodel('Honda');pubfunction()">Honda</a></li>
                    </ul>


------解决方案--------------------
getElementsByTagName("a");


------解决方案--------------------
JScript code

function pubfunction()
                    {
                        var liarr = document.getElementById("brandul").getElementsByTagName("li");
                        for(var i=0;i<liarr.length;i++)
                        {
                            liarr[i].onclick=function()
                            {
                                document.getElementById("brandstyle").style.display="none";
                                document.getElementById("ibay_search_1").innerHTML = document.getElementById("ibay_search_1").getElementsByTagName("a")..getAttribute("rel");
                            }
                        }
                            
                    }