Jquery选择器参考:http://www.w3school.com.cn/jquery/jquery_selectors.asp

模态框:http://www.runoob.com/bootstrap/bootstrap-modal-plugin.html

获取class="a"元素点击:

$(".a").click(function()
{
var name1 = $(this).attr('name'); //$(this)是当前HTML元素,获取当前元素的name值
var value1 = $(this).attr('value'); //获取当前元素的value值
var n = name1.split(":")[0]; //按:分词
$("#tablelist option").remove(); //去掉id为tablelist的select标签下面的所有option标签(初始化select标签)
$.post("/django/",{n:name1,v:value1},function(result){
var dict = eval("("+result+")"); //ajax返回的json数据需要通过eval方法被js使用
for (x in dict){
$("#db"+value1).append("<option>"+dict[x]+"</option>"); //在id为"db"+value1的元素中(示例假设是个select标签)添加<option>标签
}
});
});

获取id为tablelist的select标签的点击事件

<script>
$(document).ready(function()
{
$("#privilegelist").children("li").remove(); //去除ul标签中所有的li标签
$("#tablelist").change(function()
{
$(this).children('option:selected').attr('value');
$(this).children('option:selected').text(); //获取选项值的文本
alert();
});
});
</script>

动态添加元素的事件,高版本live用on方法替换

$(".monitoritem").live('click',function()
{
var monitoritemname = $(this).attr('name');
$('#'+monitoritemname).remove();
});

遍历元素的子元素不含孙元素

$("#openmonitorpage").click(function()
{
var a = $('#monitoritemlist').children().length;
alert(a);
$('#monitoritemlist').children().each(function(){
alert($(this).attr("name"));
});
});

使用jquery实现以post打开新窗口

function monitorpost(URL, PARAMS) {
var temp_form = document.createElement("form");
temp_form.action = URL;
temp_form.target = "_blank";
temp_form.method = "post";
temp_form.style.display = "none";
for (var x in PARAMS) {
var opt = document.createElement("textarea");
opt.name = x;
opt.value = PARAMS[x];
temp_form.appendChild(opt);
}
document.body.appendChild(temp_form);
temp_form.submit();
} #调用
monitorpost('/mysqlmonitorlist/',{'a':'123'});
#鼠标浮动弹出层
$(".mousenameserver").mouseenter(function()
{
var instancegroup = $(this).attr('name');
var ps = $(this).position();
$("#"+instancegroup+"_nameserver").css("position", "absolute");
$("#"+instancegroup+"_nameserver").css("left", ps.left + 50); //距离左边距
$("#"+instancegroup+"_nameserver").css("top", ps.top + -20); //距离上边距
$("#"+instancegroup+"_nameserver").css("background", "#fff"); //距离上边距
$("#"+instancegroup+"_nameserver").show();
}); $(".mousenameserver").mouseleave(function()
{
var instancegroup = $(this).attr('name');
$("#"+instancegroup+"_nameserver").hide();
});

判断输入框ip合法性

转:http://blog.csdn.net/stpeace/article/details/26967713

<input id="xxx" onblur="fun();" />  

<script>
function isValidIP(ip)
{
var reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/
return reg.test(ip);
} function fun()
{
var ip = document.all.xxx.value;
if(isValidIP(ip))
{
alert("yes");
}
else
{
alert("no");
}
}
</script>

注意:

1、选择器中若使用变量,变量不能有点.

CSS

距离控制

margin-top: 5px;

margin-right:10px;

区域限高

height: 450px;

max-height: 450px;

overflow:auto; 滚动条

背景颜色

background: #E4E3E3;

字体颜色

color:#363030;

【JavaScript】常用方法的更多相关文章

  1. Javascript常用方法函数收集(二)

    Javascript常用方法函数收集(二) 31.判断是否Touch屏幕 function isTouchScreen(){ return (('ontouchstart' in window) || ...

  2. javascript常用方法和技巧

    浏览器变编辑器 data:text/html, <style type=;right:;bottom:;left:;}</style><div id="e" ...

  3. javascript常用方法 - Array

    //1.Aarry方法 // 1.1 Array.from(arrayLike[, mapFn[, thisArg]]) // @arrayLike 想要转换成数组的伪数组对象或可迭代对象. // @ ...

  4. javascript常用方法 - String

    // 1.长字符串 // 1.1 let longString1 = "This is a very long string which needs " + "to wr ...

  5. JQuery和JavaScript常用方法的一些区别

    jquery 就对javascript的一个扩展,封装,就是让javascript更好用,更简单,为了说明区别,下面与大家分享下JavaScript 与JQuery 常用方法比较   jquery 就 ...

  6. Javascript常用方法函数收集(一)

    1.字符串长度截取 function cutstr(str, len) { var temp, icount = 0, patrn = /[^\x00-\xff]/, strre = "&q ...

  7. JavaScript常用方法100种

    1.输出语句:document.write(""); 2.JS中的注释为// 3.传统的HTML文档顺序是:document->html->(head,body) 4. ...

  8. javascript常用方法函数收集

    收集了一些比较常用的javascript函数. 1.字符串长度截取 function cutstr(str, len) { var temp, icount = 0, patrn = /[^\x00- ...

  9. JavaScript 常用方法总结

    经常使用的 JS 方法,今天记下,以便以后查询 /* 手机类型判断 */ var BrowserInfo = { userAgent: navigator.userAgent.toLowerCase( ...

  10. javaScript常用方法整合(项目中用到过的)

    防止输入空格.缩进等字符: function trim(str){ return str.replace(/^\s+|\s+$/g,""); } JS去掉style样式标签 fun ...

随机推荐

  1. poj1502 spfa最短路

    //Accepted 320 KB 16 ms //有n个顶点,边权用A表示 //给出下三角矩阵,求从一号顶点出发到各点的最短路的最大值 #include <cstdio> #includ ...

  2. (转)android平台phonegap框架实现原理

    (原文)http://blog.csdn.net/wuruixn/article/details/7405175 android平台phonegap框架实现原理 分类: Android2012-03- ...

  3. Python学习路程day9

    本节内容 Gevent协程 Select\Poll\Epoll异步IO与事件驱动 Python连接Mysql数据库操作 RabbitMQ队列 Redis\Memcached缓存 Paramiko SS ...

  4. Java网络应用编程

    1,网络连接 (1)用户向服务器发送请求(Socket); (2)服务器向用户发送信息(ServerSocket),一直监听的话用.accept(); 2,信息发送与接收 (1)客户向服务器端发送信息 ...

  5. Linux的sed命令

    一.初识sed 在部署openstack的过程中,会接触到大量的sed命令,比如 # Bind MySQL service to all network interfaces.sed -i 's/12 ...

  6. PyCharm5.0.2最新版破解注册激活码(图文版)

    下载PyCharm http://download-cf.jetbrains.com/python/pycharm-professional-5.0.2.exe 安装PyCharm 设置激活服务器   ...

  7. sscanf,sscanf_s及其相关用法

    #include<stdio.h> 定义函数 int sscanf (const char *str,const char * format,........); 函数说明  sscanf ...

  8. CentOS 7 为firewalld添加开放端口及相关资料

    1.运行.停止.禁用firewalld 启动:# systemctl start  firewalld 查看状态:# systemctl status firewalld 或者 firewall-cm ...

  9. xmind的第八天笔记

  10. App.config/Web.config 中特殊字符的处理

    我们知道在应用程序中嵌入连接字符串可能导致安全漏洞和维护问题.使用 Ildasm.exe(MSIL 反汇编程序) 工具可以查看编译到应用程序源代码中的未加密连接字符串.此外,如果连接字符串发生更改,则 ...