click

Jquery实例练习

匿名 (未验证) 提交于 2019-12-02 21:53:52
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style> #cover{ position: fixed; left: 0; right: 0; top: 0; bottom: 0; background: rgba(0,0,0,0.3); z-index: 99; } #model { position: absolute; width: 400px; height: 200px; margin-top:-100px ; margin-left: -200px; left: 50%; top: 50%; z-index: 100; background: white; } .hide { display: none; } </style> </head> <body> <div id="cover" class="hide usrtag"></div> <div id="model" class="hide usrtag"> <label> 用户: <input id='name' type="text"> </label> <hr> <label> 密码: <input id="hobby" type="text"> </label> <hr>

HTML自制计算器

匿名 (未验证) 提交于 2019-12-02 20:32:16
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title>自制计算器</title> 6 <link href="css/bootstrap.css" rel="stylesheet" /> 7 <script src="js/bootstrap.js"></script> 8 <script src='F:\JavaScript实例\jquery-1.7.2.js'></script> 9 <script type="text/javascript"> 10 $(function(){ 11 var $btn=$("#calc") 12 // 取消已绑定的事件: 13 $btn.off('click'); 14 $btn.click(function() { 15 var x=parseFloat($('#x').val()), 16 op=$('#op').val(), 17 y=parseFloat($('#y').val()), 18 r; 19 r=x+op+y; 20 document.getElementById("result").value=eval(r); 21 // alert('计算结果:'+r); 22 try{ 23 if(isNaN(x)||isNaN(y)){ 24

jquery click event not firing on dynamically created div

不羁的心 提交于 2019-12-02 20:24:34
问题 i'm setting a click event on a div that is dynamically created in a jqueryUI drop event (part of draggable), the click event will remove the div. That works fine. Inside of document.ready I do the same thing, based on data from local storage. I can create the dynamic divs, but the click event does not bind, or the binding is lost. I've tried using "click", "live" and "on". I've also removed the loop it sits in and just attached to the first item, none of it works when sitting directly in $

Why does mousedown event listener run through function?

允我心安 提交于 2019-12-02 18:48:11
问题 I drew a canvas, and then with the code canvas.addEventListener("mousedown", clicked(event), false); I added an event listener to run clicked whenever I click the mouse. But when I went through the code line by line on chrome, the moment it adds the event listener it automatically runs the function clicked anyway, but I only want it to run the function when I click. Am I doing something wrong? 回答1: You need to just pass the function reference and not actually call it like this: canvas

Add ondrop - ondragover to the new created element not working

被刻印的时光 ゝ 提交于 2019-12-02 17:47:35
问题 Every child-div is clicking. Within the divs there is a dragdiv, which can be dragged into a child div. Clicking the AddChild button creates a new child-div that is not an ondrop-ondragover. How can every new child-div get drag-div? I tried: y.addEventListener ('ondrop', function () {drag (ev)}, false); y.addEventListener ('ondragover', function () {drag (ev)}, false); <style> #divs{ width: 450px; height: 70px; margin: 10px; padding: 10px; background-color: blue; } #dragdiv{ width: 50px;

Jquery to detect identical class and text for tab navi

假如想象 提交于 2019-12-02 17:30:29
问题 Does anyone have experience detecting identical text(); and class? here is my current code to $("ul.nav li").click(function() { $('ul.slideMove li').fadeOut('slow'); var sharedata = $(this).text(); $('ul.slideMove li[class = "'+sharedata+'" ]').fadeIn('slow'); }); the final goal will be to have tabbed navigation. When the text in ul.nav li is the same as a class within the the dynamic container, fadeIn(). On initial load, only one container will be visible then hide and show another container

jQuery .click function is not working without a string

▼魔方 西西 提交于 2019-12-02 17:04:41
问题 Link to first question: Ruby on Rails and Jquery: trying to switch characters after submit I asked this question yesterday, and got what I believe to be some helpful feedback, but now I am now lost as to what is going wrong. I'm trying to build a tic-tac-toe game in RoR, and at the moment I'm stuck at trying to switch players after the page is submitted. jQuery: $(document).ready(function(){ var currentPlayer = $(#table).data("current-player"); $(".square").click(function(){ // Gather the

How to do “If Clicked Else ..”

孤者浪人 提交于 2019-12-02 16:49:45
I am trying to use jQuery to do something like if(jQuery('#id').click) { //do-some-stuff } else { //run function2 } But I'm unsure how to do this using jQuery ? Any help would be greatly appreciated. Edit: I'm trying to run a function if the #id has been clicked and specifically it is has not been clicked then run the function 2 ? i.e. I need to check firstly that the #id has been clicked before running function2 ? You should avoid using global vars, and prefer using .data() So, you'd do: jQuery('#id').click(function(){ $(this).data('clicked', true); }); Then, to check if it was clicked and

Programmatically press a button on another application (C, Windows)

帅比萌擦擦* 提交于 2019-12-02 15:56:38
I'm trying to use the following code to press a button on my other application: HWND ButtonHandle; if( (wnd = FindWindow(0, "Do you want to save?")) ) { ButtonHandle = FindWindowEx(wnd, 0, "SaveButton", "&Save"); SendMessage(wnd, WM_COMMAND, MAKEWORD(GetDlgCtrlID(ButtonHandle), BN_CLICKED ), (LPARAM)ButtonHandle); } It doesn't work. I tried passing different handles to MAKEWORD and to change the WPARM and LPARAM but nothing. Any ideas on how to click a button on another application's window? Code is appreciated. Thanks. EDIT: The reason it doesn't seem to work permissions. I sent a PostMessage