首页 > 代码库 > 小部分ajax的控制,两种实现状态,两段js(纯属自己做给自己看的)

小部分ajax的控制,两种实现状态,两段js(纯属自己做给自己看的)

<div class="houseList" ><div class="one111_" id="one111_">
<h3>一/二</h3>
<ul class="list">
<li >
<span class="fleft">一:</span>
<!--
EOT;
$sel = $_viewer->plate ? ‘class="area"‘ : ‘‘;
$areaall = !$_viewer->areatype ? ‘abc‘ : ‘‘;
print <<<EOT
-->
<!--
EOT;
foreach ( $_viewer->area as $key=>$value ) {
$sel = ($_viewer->areatype == $key) ? ‘class="act"‘ : ‘‘;
print<<<EOT
-->
<li style="display:inline"><a id="one3_{$key}">{$value}</a></li>
<!--
EOT;
}
print<<<EOT
-->
</li>
<li>
<span class="fleft">二:</span>
<!--
EOT;
$sel = $_viewer->plate ? ‘class="area"‘ : ‘‘;
$areaall = !$_viewer->areatype ? ‘abc‘ : ‘‘;
print <<<EOT
-->
<!--
EOT;
foreach ( $_viewer->area as $key=>$value ) {
$sel = ($_viewer->areatype == $key) ? ‘class="act"‘ : ‘‘;
print<<<EOT
-->
<li style="display:inline"><a id="one4_{$key}">{$value}</a></li>
<!--
EOT;
}
print<<<EOT
-->
</li>
</ul>


</div>

<div id="areas" style="display:none;">
<!--
EOT;
foreach ( $_viewer->steets as $key=>$value ) {
print<<<EOT
-->
<div class="areas{$key}">
<!--
EOT;
foreach($value as $streets){
print<<<EOT
-->
<a href="http://www.mamicode.com/index-htmx-m-house-q-sale-act--options-
{$_viewer->options[areatype]}opt.areatype.{$key}.{$_viewer->options[platetype]}opt.platetype.{$streets[‘streetid‘]}.html">{$streets[‘name‘]}</a>
<!--
EOT;
}
print<<<EOT
-->
</div>
<!--
EOT;
}
print<<<EOT
-->
</div>

<div class="tab1" id="tab1">
<div id="footer" class="regionalLinks" onclick="setTab(‘one‘,0)">
<ul>
<li><a href="javascript:scroll(0,0)">返回顶部 </a></li>
<!--
EOT;
$sel = $_viewer->plate ? ‘class="area"‘ : ‘‘;
$areaall = !$_viewer->areatype ? ‘abc‘ : ‘‘;
print <<<EOT
-->
<li><a id="one1" onm ouseover="setTab(‘one‘,1)" style="height: 36px;">一</a>
<div id="con_one_1" class="xiala_list" style="display: none; z-index: 1; margin-left: 0px; width: 460px; padding: 5px; top: 61px; left: -40px;">
<!--
EOT;
$sel = ‘‘;
foreach ( $_viewer->area as $key=>$value ) {
$sel = ($_viewer->areatype == $key) ? ‘class="act"‘ : ‘‘;
print<<<EOT
-->
<a href="http://www.mamicode.com/index-htmx-m-house-q-sale-act--options-{$_viewer->options[areatype]}opt.areatype.{$key}.html" {$sel}>{$value}</a>
<!--
EOT;
}
print<<<EOT
-->
</div>
</li>
<li>
<a id="one2" onm ouseover="setTab(‘one‘,2)" style="height: 36px;">二</a>
<div id="con_one_2" class="xiala_list" style="display: none; z-index: 1; margin-left: 0px; width: 460px; padding: 5px; top: 61px; left: -40px;">
<!--
EOT;
$sel = ‘‘;
foreach ( $_viewer->area as $key=>$value ) {
$sel = ($_viewer->areatype == $key) ? ‘class="act"‘ : ‘‘;
print<<<EOT
-->
<a href="http://www.mamicode.com/index-htmx-m-house-q-hire-act--options-{$_viewer->options[areatype]}opt.areatype.{$key}.html" {$sel}>{$value}</a>
<!--
EOT;
}
print<<<EOT
-->
</div>
</li>
</ul>
</div>

 

<script type="text/javascript">
function setTab(name,cursel){
cursel_0=cursel;
for(var i=1; i<=links_len; i++){
var regionalLinks = document.getElementById(name+i);
var menudiv = document.getElementById("con_"+name+"_"+i);
if(i==cursel){
//regionalLinks.className="off";
menudiv.style.display="block";
}
else{
//regionalLinks.className="";
menudiv.style.display="none";
}
}
}

onload=function(){
var links = document.getElementById("tab1").getElementsByTagName(‘li‘)
links_len=links.length;
for(var i=0; i<links_len; i++){
links[i].onmouseover=function(){
//clearInterval(iIntervalId);
this.onmouseout=function(){
}
}
}
}

$(function(){
$("a[id^=‘one111_‘],a[id^=‘one1_‘],a[id^=‘one2_‘],a[id^=‘one3_‘],a[id^=‘one4_‘]").mouseover(function(){
var area=$(this).attr(‘id‘);
area=area.split(‘_‘);
var areaid=area[1];
if($(this).parent().find("div.xiala_list").length<1)
{
$(this).after(‘<div class="xiala_list"></div>‘);
$(this).next("div.xiala_list").html($("div#areas div.areas"+areaid).html());
}

/*当点击另一个的时候,前一个消失*/
$(this).next("div.xiala_list").css(‘display‘,‘block‘).parents().siblings().find("div.xiala_list").hide();
})
$("body.one111_,div.one111_").click(function(){
$("div.xiala_list").css(‘display‘,‘none‘);
});
});
</script>

小部分ajax的控制,两种实现状态,两段js(纯属自己做给自己看的)