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. Allegro建立引脚封装概念名词梳理

    首先感谢于博士的60讲的Cadence教学视频,老师讲的还是很有耐心,很细致,谢谢! 目前还只是看到建立PCB封装这一块,正好手头上有个案子在做,边做边学的进度还是要好很多.以前的工作对原理图这一块的 ...

  2. PC缺少一个或多个网络协议 qq可登录(win10)

    打开适配器连接 1打开网络适配器   2卸载microsoft  3 网络客户端   4重启

  3. MVC 3.0 上传多张图片到服务器

    View关键代码: @using (Html.BeginForm("Create", "Activity", FormMethod.Post, new { en ...

  4. 18、(番外)匿名方法+lambda表达式

    概念了解: 1.什么是匿名委托(匿名方法的简单介绍.为什么要用匿名方法) 2.匿名方法的[拉姆达表达式]方法定义 3.匿名方法的调用(匿名方法的参数传递.使用过程中需要注意什么) 什么是匿名方法? 匿 ...

  5. C++嵌入Python,以及两者混用

    以前项目中是C++嵌入Python,开发起来很便利,逻辑业务可以放到python中进行开发,容易修改,以及功能扩展.不过自己没有详细的研究过C++嵌入python的细节,这次详细的研究一下.首先我们简 ...

  6. Map/Reduce 工作机制分析 --- 错误处理机制

    前言 对于Hadoop集群来说,节点损坏是非常常见的现象. 而Hadoop一个很大的特点就是某个节点的损坏,不会影响到整个分布式任务的运行. 下面就来分析Hadoop平台是如何做到的. 硬件故障 硬件 ...

  7. firefox 不识别background-position-y / background-position-x

    火狐不识别background-position-y 或background-position-x; 案例: 页面: 背景图: 一列按钮,点击时让当前背景图的background-position-y ...

  8. H5版定点投篮游戏(1)--物理模型抽象

    前言: 前几天目睹了大学同学开了个微店, 算是间接体验微信公众平台的使用. 觉得非常便捷和方便, 于是自己也想捣鼓一个. 公众号取名: "木目的H5游戏世界", 定位做成一个, 个 ...

  9. xmind的第七天笔记

  10. Latex转换之PDF

    近期一直在做如何使用latex将模板转换成PDF.现在写下在项目中如何实现. 1.首先你先进官网下载http://www.miktex.org/download.我用的是如下图所示. 在下载好的Mik ...