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. Oracle 11gR2 安装教学

    官方网址:http://www.oracle.com/index.html 选择你的"操作系统"下载 例如: 环境:x64 Win2012 R2 Oracle:win64_11gR ...

  2. RBL开发笔记三

    2014-08-26 20:06:24 今天就是在开发这个EPOLL来处理网络事件 封装较为健壮的EPOLL模型来处理基本的网络IO 1) 超时这个主题先没有弄 在开发EPOLL包括select/po ...

  3. 最短路径问题——dijkstra算法

    仅谈谈个人对dijkstra的理解,dijkstra算法是基于邻接表实现的,用于处理单源最短路径问题(顺便再提一下,处理单源最短路径问题的还有bellman算法).开辟一个结构体,其变量为边的终点和边 ...

  4. hdu4691 Front compression ——暴力 || 后缀数组

    link:http://acm.hdu.edu.cn/showproblem.php?pid=4691 暴力,数据明显太水了吧,n=10^5, O(n^2)的复杂度哎喂.想让大家暴力写直接让n=100 ...

  5. POJ 1006 中国剩余定理

    #include <cstdio> int main() { // freopen("in.txt","r",stdin); ; while(sca ...

  6. Deleting backup_label on restore will corrupt your database!

    The quick summary of this issue is that the backup_label file is an integral part of your database c ...

  7. Sea.js学习4——Sea.js的配置

    可以对 Sea.js 进行配置,让模块编写.开发调试更方便. seajs.config seajs.config(options) 用来进行配置的方法. seajs.config({ // 别名配置 ...

  8. IntelliJ IDEA15导入jar包

    在IDEA中导入jar包和eclipse中是不一样的,那么现在我们就来看看在IDEA中如何导入jar包. 1.点击"File"-->"Project Structu ...

  9. 怎么 才能显示Eclipse中Console的全部内容

    可以如下设置 preference->run/debug->console 设置limit console output 为false,方便调试时,查看全部console. 这个真是太有用 ...

  10. Mustache 使用心得总结

    Mustache 使用心得总结 前言: 之前的一个项目里面就有用到这个前台的渲染模版,当时挺忙的也没时间抽空总结一下,刚好上周项目里又用到这个轻量型的渲染模版,真心感觉很好用,因此就总结一下使用心得, ...