首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

小弟我有两个超链接,用jquery写 如何控制这两个超链接

2012-04-21 
我有两个超链接,用jquery写 怎么控制这两个超链接例如:a ida1 href..a1/aa ida2 href..

我有两个超链接,用jquery写 怎么控制这两个超链接
例如:<a id="a1" href="..">a1</a>
  <a id="a2" href="..">a2</a>
用jquery写 怎样才能实现如下功能:
  当我点击a1后 就不能在点击a1了,继续点击a1失去效果,这时只能点击a2;点击a2后,a1可以再次点击,但是a2就不能再此点击了,除非点击a1后,如此循环 ,求高手解答,急。。。。。
   
 

[解决办法]
$("#a1").client()

说下思路吧。。获取A1 和A2的href值。 a1触发事件的时候a1的href值清空。并保持到临时变量中。可以是隐藏域。然后当a2触发事件的时候a2的href值清空。并且把临时值传给a1、、
a1的事件

JScript code
if(document.getElementById("隐藏域").value==""){document.getElementById("隐藏域").value =document.getElementById("a1").href;document.getElementById("a1").href="";}else{document.getElementById("a2").href=document.getElementById("隐藏域").value;document.getElementById("隐藏域").value =document.getElementById("a1").href;document.getElementById("a1").href="";}a2事件document.getElementById("a1").href=document.getElementById("隐藏域").value ;document.getElementById("隐藏域").value =document.getElementById("a2").href;document.getElementById("a2").href="";<a>a1</a><a>a2</a><input id="隐藏" value>
[解决办法]
探讨

$("#a1").client()

说下思路吧。。获取A1 和A2的href值。 a1触发事件的时候a1的href值清空。并保持到临时变量中。可以是隐藏域。然后当a2触发事件的时候a2的href值清空。并且把临时值传给a1、、
a1的事件
JScript code
if(document.getElementById("隐藏域").value=="")
{document.getEl……

[解决办法]
写了一个比较笨的方法。
JScript code
<script type="text/javascript">    var a3="true";    var a4="true";    $(document).ready(function(){            $("#a3").bind({            "click":function(){                if(a3=="true"){                        window.open("www.baidu.com","_blank");                    a3="false";                    a4="true";                }            },            "mouseover":function(){                if(a3=="true"){                    $("#a3").css("text-decoration","underline");                    $("#a3").css("cursor","hand");                }                    },            "mouseout":function(){                if(a3=="true"){                    $("#a3").css("text-decoration","");                    $("#a3").css("cursor","");                }                    },            "mouseup":function(){                if(a3=="true"){                    $("#a3").css("text-decoration","");                    $("#a3").css("cursor","");                }                    }        });        $("#a4").bind({            "click":function(){                if(a4=="true"){                    window.open("www.google.com","_blank");                    a4="false";                    a3="true";                }            },            "mouseover":function(){                if(a4=="true"){                    $("#a4").css("text-decoration","underline");                    $("#a4").css("cursor","hand");                }                    },            "mouseout":function(){                if(a4=="true"){                    $("#a4").css("text-decoration","");                    $("#a4").css("cursor","");                }                    },            "mouseup":function(){                if(a4=="true"){                    $("#a4").css("text-decoration","");                    $("#a4").css("cursor","");                }                    }        });    });            </script> 

热点排行