click

(10)打鸡儿教你Vue.js

无人久伴 提交于 2020-02-27 04:45:26
事件处理器 <div id="app"> <button v-on:click="counter += 1">增加 1</button> <p> {{ counter }} 次。</p> </div> <script> new Vue({ el: '#app', data: { counter: 0 } }) </script> <div id="app"> <!-- `greet` 是在下面定义的方法名 --> <button v-on:click="greet">Greet</button> </div> <script> var app = new Vue({ el: '#app', data: { name: 'Vue.js' }, methods: { greet: function (event) { alert('Hello ' + this.name + '!') // `event` 是原生 DOM 事件 if (event) { alert(event.target.tagName) } } } }) // 也可以用 JavaScript 直接调用方法 app.greet() // -> 'Hello Vue.js!' </script> <div id="app"> <button v-on:click="say('hi')">Say hi</button>

前端学习之jquery

喜欢而已 提交于 2020-02-26 05:08:43
一 jQuery是什么? <1> jQuery 由美国人 John Resig 创建,至今已吸引了来自世界各地的众多 javascript 高手加入其 team 。 <2>jQuery 是继 prototype 之后又一个优秀的 Javascript 框架。其宗旨是 ——WRITE LESS,DO MORE ! <3>它是轻量级的 js 库 ( 压缩后只有 21k) ,这是其它的 js 库所不及的,它兼容 CSS3 ,还兼容各种浏览器 ( IE 6.0+, FF 1.5+, Safari 2.0+, Opera 9.0+ )。 <4>jQuery 是一个快速的,简洁的 javaScript 库,使用户能更方便地处理 HTML documents 、 events 、实现 动画效果,并且方便地为网站提供 AJAX 交互。 <5>jQuery 还有一个比较大的优势是,它的文档说明很全,而且各种应用也说得很详细,同时还有许多成熟的插件 可供选择。 二 什么是 jQuery 对象? jQuery 对象就是通过 jQuery 包装 DOM 对象后产生的对象。 jQuery 对象是 jQuery 独有的 . 如果一个对象是 jQuery 对象 , 那么它就可以使用 jQuery 里的方法 : $(“#test”).html(); $("#test").html() //意思是指

jQuery click fires twice but only registered once

瘦欲@ 提交于 2020-02-25 04:21:33
问题 I have an element click event that's firing twice on a single click, a common issue from searching, but I've ruled out may of the potential causes from other answers. The code is console.log("registering label click"); $("label.tiletype").click( function(event) { event.stopPropagation(); // stop the .tile click being called console.log("label clicked, x = " + event.pageX + ", y = " + event.pageY); // more code... } } When the page is loaded and the "label.tiletype" clicked, the log is

Compare 'e.target' to a jQuery object

和自甴很熟 提交于 2020-02-19 07:58:59
问题 What I want to do: ( clickedObject === someDiv ) //returns true or false What I tried ( $(e.target) === $('.selector') ); //returns a false negative. My workaround ( $(e.target).attr('class') === $('.selector').attr('class') ); //works as intended, not so clean though. What is the right way to compare the object I clicked to an object in the DOM? 回答1: To check if e.target has this class you can use the hasClass function. if ($(e.target).hasClass("selector")) Or, if you really want to compare

Compare 'e.target' to a jQuery object

放肆的年华 提交于 2020-02-19 07:58:06
问题 What I want to do: ( clickedObject === someDiv ) //returns true or false What I tried ( $(e.target) === $('.selector') ); //returns a false negative. My workaround ( $(e.target).attr('class') === $('.selector').attr('class') ); //works as intended, not so clean though. What is the right way to compare the object I clicked to an object in the DOM? 回答1: To check if e.target has this class you can use the hasClass function. if ($(e.target).hasClass("selector")) Or, if you really want to compare

HTML 学习笔记 JQuery(锋利的JQuery 代码)

馋奶兔 提交于 2020-02-17 11:17:03
一 制作简单的导航栏 <html> <head> <meta charset="UTF-8"> <title></title> <script type="text/javascript" src="../js/jquery-2.1.1.min.js"></script> <style type="text/css"> #menu {width: 300px;} /*cursor 规定光标的显示类型*/ .has_children{background: #555555; color: #ffffff;cursor: pointer;} .highlight{color: #ffffff; background: green;} div { /*内间距*/ padding: 1px; clear: left; } div a { background: #888888; /*标签a先不显示*/ display: none; float: left; margin: 2px; widows: 300px; } </style> <script> $(function() { //为class = "has_children"的div添加点击事件 $(".has_children").click(function() { $(this).addClass("highlight") /

ajax-jquery无刷新分页

做~自己de王妃 提交于 2020-02-08 01:14:06
前台JS代码: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 //ajax无刷新分页 function btnList() { var current = 1; $.post( "NoRefreshPage.ashx" , { "action" : "pagenum" }, function (data, status) { //func开始 if (status == "success" ) { //if开始 $( "#trPage" ).empty(); $( "#trPage" ).append( "<td title=tdprev><a href=''>上一页</a></td>" ); //添加上一页 $( "#trPage td[title='tdprev']" ).click( function (e) { e.preventDefault(); if (parseInt(current) > 1) { $( "

Sending a button press event for a second pointing device

假如想象 提交于 2020-02-06 09:50:46
问题 So I want to make left mouse clicks using another pointing device (that can be created with e.g. xinput create-master mouse ) but those clicks shouldn't give focus to windows. This is what I got so far: (Compile this code with gcc -lX11 -lXtst -lXext -o test test.c and move your mouse over e.g. text that is inside of a text editor like Kate) #include <X11/Xlib.h> // Simulate mouse click void click (Display *display, int button) { // Create and setting up the event XEvent event; event.xbutton

Sending a button press event for a second pointing device

北慕城南 提交于 2020-02-06 09:50:43
问题 So I want to make left mouse clicks using another pointing device (that can be created with e.g. xinput create-master mouse ) but those clicks shouldn't give focus to windows. This is what I got so far: (Compile this code with gcc -lX11 -lXtst -lXext -o test test.c and move your mouse over e.g. text that is inside of a text editor like Kate) #include <X11/Xlib.h> // Simulate mouse click void click (Display *display, int button) { // Create and setting up the event XEvent event; event.xbutton

Am I going crazy? jQuery .click() doesn't seem to work

谁说胖子不能爱 提交于 2020-02-04 04:49:44
问题 Code below doesn't work on any browser. It's supposed to show an alert box. What am I doing wrong? <html> <head> <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.3.min.js"></script> <script type="text/javascript"> $('#prevlink').click(function () { alert("Test"); }); </script> </head> <body> <a id="prevlink" href="#">test</a> </body> </html> 回答1: You are not wrapping the function in a ready() event. It runs before the DOM exists. 回答2: Put it in document.ready! 回答3: You're