zoukankan      html  css  js  c++  java
  • MY JQUERY NOTES

    windows的方法之一

    • 警告窗 alert
    • 确认窗 confir
    • 弹出输入框 prompt
      alart简单代码使用
    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>1</title>
    </head>
       <button id="div1" type="button" value="警告窗">alert</button>
       <script type="text/javascript">
         div1.onclick=function(){
       	  alert('这是一个警告窗')
         };
       </script>
    <body>
    </body>
    </html>
    
    

    confirm函数示例,返回true/false

    <script type="text/javascript">
         div1.onclick=function(){
       	  if(!confirm('你想放假吗?')){
       		  confirm('你真的不想放假吗?')
       	  }
       	  
         };
    </script>
    
    
    • 还没有写对的正确代码
    <!doctype html> 
    <html> 
    <head> 
       <meta charset="utf-8"> 
       <title></title> 
    </head>
    <body>
       <div id='div1'>go</div>
       <script type="text/javascript">
    
       	function to(){
       		if(!confirm('你觉得我帅么?')){
       			to();
       		}
       		else{
       			alert('你真有眼光!');
       		}
       	}
    
       	div1.onclick = function(){
       		to()
       	};
       </script>
    </body>
    </html>
    

    prompt返回值或空(null)

    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>1</title>
    </head>
       <button id="div1" type="button" value="警告窗">点我点我</button>
       <script type="text/javascript">
         div1.onclick=function(){
       	  if(prompt("世界上最高峰是什么")!='珠穆朗玛峰'){
       		  alert('不对哦')
       	  }
       	  else{
       		  alert('嗯呗')
       	  }
         };
    </script>
    
    <body>
    </body>
    </html>
    

    jquery $和$()区别

    • $代表jQuery对象,同时也是一个函数对象
    • $()jQuery()是jQuery的核心函数,执行这两个元素返回的是一个DOM元素
    • $()是一个函数,等同于jQuery(),可在括号内传参数,传参后可获取元素
    • $(".one")表示获取class=“one"的元素,返回一个jQuery对象
    • $(”.one").onclick表示class="one"的点击事件
    • $.post()$.get()$.ajax()都是jQuery对象的方法
    • $(document)就是 选取整个文档对象

    jquery $(this)

    this通常是一个Html 元素,例如(textbox),textbox有text属性。可以在textbox的事件里面引用this获取元素,$(this)通常是一个JQuery对象 ,可以调用jquery的方法和属性值,例如click(), keyup()。
    例如:

    $(function () {
    $('button').click(function () {
    $(this)表示当前对象,这里指的是button
    //alert(this);//this 表示原生的DOM
    })
    });
    
    • $(this).attr(key); 获取节点属性名的值,相当于getAttribute(key)方法
    • $(this).attr(key, value); 设置节点属性的值,相当于setAttribute(key,value)方法
    • $(this).val();获取某个元素节点的value值,相当于$(this).attr(“value”);
    • $(this).val(value);设置某个元素节点的value值,相当于$(this).attr(“value”,value);

    jquery怎么操作json

    https://www.php.cn/js-tutorial-466109.html

    用javascript判断checkbox是否选中?

    用getElementById得到变量,例如var name=document.getElementById("anyid");,若name.checked==true表示被选中。

    js动态添加和移除disabled属性

    原文链接:https://blog.csdn.net/qq_41523985/article/details/82078599

    js操作

    function disableTest(element,val){
        document.getElementById(element).disabled=val;
    }
     document.getElementById("uid").disabled="";
    

    jquery操作

    //两种设置disabled属性
    $('#uid').attr("disabled",true);
    $('#uid').attr("disabled","disabled");
    //三种移除disabled属性
    $('#uid').attr("disabled",false);
    $('#uid').removeAttr("disabled");
    $('#uid').attr("disabled","");
    
  • 相关阅读:
    Linq聚合操作之Aggregate,Count,Sum,Distinct源码分析
    Linq分区操作之Skip,SkipWhile,Take,TakeWhile源码分析
    Linq生成操作之DefautIfEmpty,Empty,Range,Repeat源码分析
    Linq基础操作之Select,Where,OrderBy,ThenBy源码分析
    PAT 1152 Google Recruitment
    PAT 1092 To Buy or Not to Buy
    PAT 1081 Rational Sum
    PAT 1084 Broken Keyboard
    PAT 1077 Kuchiguse
    PAT 1073 Scientific Notation
  • 原文地址:https://www.cnblogs.com/LiuYUE-fusheng/p/15213457.html
Copyright © 2011-2022 走看看