JS:实用功能

ylbtech-jQuery:函数-导航
jQuery:3.1,添加样式(addClass)、移除样式(removeClass) 返回顶部
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
.selected{ background-color:red}
</style>
<script type="text/javascript" src="jquery-1.4.1.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    $("p").toggle(function(){
        $(this).addClass("selected");
    },function(){
        $(this).removeClass("selected");
    });
});
</script>
</head>

<body>
<p>ylbtech</p>
<p>ylbtech</p>
<p>ylbtech</p>
<p>ylbtech</p>

</body>
</html>
jQuery:3.2,轮替函数(toggle()) 返回顶部
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
.select{background-color:red;
}
</style>
<script type="text/javascript" src="jquery-1.4.1.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    $("#btn1").click(function(){
        $(this).addClass("select");
    });
    $("#btn2").click(function(){
        $(this).removeClass("select");
    });
    $("#btn3").click(function(){
        $(this).toggleClass("select");
    });
});
</script>
</head>

<body>
<input id="btn1" type="button"  value="ajax1" />
<input id="btn2" type="button"  value="ajax2" class="select" />
<input id="btn3" type="button"  value="ajax1" />
</body>
</html>
jQuery:3.3,选项拼加 返回顶部
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript">
function list(check_b,txt)
{
    var str_S=txt.value;
    var str_C=check_b.value;
    if(check_b.checked==true)
    {
        txt.value=str_S+str_C;
    }
    else
    {
        str_S=str_S.replace(str_C,"");
        txt.value=str_S;
    }
}
</script>
</head>

<body>
我们选择了:<input type="text" name="t_1" value="" readonly="true" />
<br />
<input type="checkbox" value="苹果 " onclick="list(this,t_1)" >苹果</input>
<input type="checkbox" value="香蕉 " onclick="list(this,t_1)" >香蕉</input>
<input type="checkbox" value="芹菜 " onclick="list(this,t_1)" >芹菜</input>
</body>
</html>
jQuery:3.4全选 返回顶部
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script language="javascript">
function ca()
{
    for(i=0;i<f.news.length;i++)
    {    
        f.news[i].checked=f.all.checked;
    }
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />

<title>无标题文档</title>
</head>

<body><br />
<form name="f" style="font-size:36px">
全选<input type="checkbox" name="all" onclick="ca()"/><br />
军事<input type="checkbox" name="news"/><br />
政治<input type="checkbox" name="news"/><br />
娱乐<input type="checkbox" name="news"/><br />
体育<input type="checkbox" name="news"/><br />
</form>
</body>
</html>
jQuery:3.5网页刷点器 返回顶部
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>袁博刷点 高效一流</title>
<script language="javascript">
var count=3;
var sumcount=100;//默认100次
var intervalid;
var url;
function funfirst()
{
    intervalid=setInterval("fun1()",1000)
    var txtsum=document.getElementById("txtcount").value;
    if(txtsum.length!=0)
    {
        sumcount=parseInt(txtsum);
    }    
}
function fun1()
{
    sumcount--;
    var onclickurl=document.getElementById("txturl").value;    
    url=window.open("http://"+onclickurl,"_blank","");    
    if(sumcount<=1)
    {
      fun3();
    }
    fun2();
}
function fun2()
{
    count--;
    if(count<0)
    {
        url.close();
    }
}
function fun3()
{
    clearInterval(intervalid);
}
</script>

</head>

<body>

请在下输入你想要刷的网址(注:本产品仅支持在IE浏览器使用)
<table width="326" border="1">
  <tr>
    <td width="168"><input type="text" id="txturl"  /></td>
    <td width="68"><input type="button" value="开始刷点" onclick="funfirst()"></td>
    <td width="68"><input type="button" value="停止刷点" onclick="fun3()" /></td>
  </tr>
  <tr>
    <td height="33">格式如:www.baidu.com</td>
    <td>刷点次数</td>
    <td><input type="text" id="txtcount"  width="20px" />
    默认为100次</td>
  </tr>
</table>

</body>
</html>

 

warn 作者:ylbtech
出处:http://ylbtech.cnblogs.com/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
posted on 2013-06-25 23:22  ylbtech  阅读(395)  评论(0编辑  收藏  举报