onclick

unbind onclick event for 'a' inside a div with onclick event

回眸只為那壹抹淺笑 提交于 2020-01-04 09:05:32
问题 html: <div id="container"> <div class="desc">desc</div> <a href="foo.php">foo</a> </div> js: $('#container').click(function(){ ... my_function(); ... }); This works when the user click inside container except for the a tag. If the user click a tag, the click event fires. However, I want to disable self-defined click function for a tag. That is, link to the page without the onlick event. This doesn't work: $('#container :not(a)').click(); 回答1: Check if the event originates from the a tag, like

getting inner html of a link when clicked

◇◆丶佛笑我妖孽 提交于 2020-01-04 02:49:31
问题 I have an HTML Link and a p tag as follows: <a href="#" onclick="myfun()">Computer Science</a> <p id="putpara"></p> This Is My Function : function myfun() { document.getElementById("putpara").innerHTML = this.innerHTML; } However when i click the link the content inside the paragraph tag changes to undefined . Seems like a silly mistake i am making.....Newbie to javascript.... 回答1: One solution is to send this parameter in your function like this: html <a href="#" onclick="myfun(this)"

漂亮的JS日历控件

耗尽温柔 提交于 2020-01-04 02:20:47
代码如下: <script> /* alin */ /* Email:caoailin111@sohu.com */ /* QQ:38062022 */ /* Creation date: 2004-6-13 */ var myC_x,myC_y; var myC_timeset=null,myC_timeset1=null; var divObj=null; var inputName; function myCalendar() //构建对象 { var myDate = new Date(); this.year = myDate.getFullYear(); this.month = myDate.getMonth()+1; this.date = myDate.getDate(); this.format="yyyy-mm-dd"; this.style = myStyle(1);  this.show = createCalendar; this.input = createInput; } function myStyle(num) //设置样式 { if(!num||isNaN(num)){alert('参数不对,采用默认样式!');num=1;}  var style = new Array(); style[1]=".week{background-color:

How to hide a div by clicking a button?

限于喜欢 提交于 2020-01-03 18:47:01
问题 In my angular.js learning project I want to hide one div and show another when I click a button. In this code, I'd like the first div to be hidden at the click (or even destroyed?) and the second div to be shown. Basically I want the user experience of going from page 1 to page 2 in my app. How do I make this happen? Index.html <ion-content ng-controller="StartpageCtrl"> <div class="list card" id="startCard" ng-show="showstartCard"> <div class="item item-image item item-text-wrap"> Card 1 <

How to hide a div by clicking a button?

空扰寡人 提交于 2020-01-03 18:45:23
问题 In my angular.js learning project I want to hide one div and show another when I click a button. In this code, I'd like the first div to be hidden at the click (or even destroyed?) and the second div to be shown. Basically I want the user experience of going from page 1 to page 2 in my app. How do I make this happen? Index.html <ion-content ng-controller="StartpageCtrl"> <div class="list card" id="startCard" ng-show="showstartCard"> <div class="item item-image item item-text-wrap"> Card 1 <

Why is ng-click not working?

丶灬走出姿态 提交于 2020-01-03 18:19:06
问题 Why on earth wont this simple ng-click example work? I've been using angular for months in production, but this plunker is baffling me. http://plnkr.co/edit/9Rp5JD?p=preview If you notice, the ng-show properties are working... why isn't the click? It always alerts the default and not the angular click. <div ng-show="showTest" ng-click="alert('angular click')" onclick="alert('default click')">Default or angular click?</div> <div ng-show="dontShowMeIsNotDefinedSoIWontShow" >Not showing me, I

jQuery: remove the closest <tr> with a dynamically added button

元气小坏坏 提交于 2020-01-03 14:51:36
问题 i am unable to remove a row in table using dynamically generated buttons. The main problem is that the "alert()" does not work. How do i catch the 'click' event? jQuery: $("#officers-table").on('click', '.remove-officer-button', function(e) { var whichtr = $(this).closest("tr"); alert('worked'); // Alert does not work whichtr.remove(); }); HTML/PHP (updated the code) <table id="officers-table" class="ui-widget ui-widget-content"> <?php if($num_officers > 0): ?> <thead> <tr class="ui-widget

jQuery: remove the closest <tr> with a dynamically added button

旧巷老猫 提交于 2020-01-03 14:48:35
问题 i am unable to remove a row in table using dynamically generated buttons. The main problem is that the "alert()" does not work. How do i catch the 'click' event? jQuery: $("#officers-table").on('click', '.remove-officer-button', function(e) { var whichtr = $(this).closest("tr"); alert('worked'); // Alert does not work whichtr.remove(); }); HTML/PHP (updated the code) <table id="officers-table" class="ui-widget ui-widget-content"> <?php if($num_officers > 0): ?> <thead> <tr class="ui-widget

Using a loop to set the buttons onclicklistener

无人久伴 提交于 2020-01-03 10:59:11
问题 I am trying to use a loop to set the action for each button when clicked (since most of the buttons will just return their text value), however I am getting an error stating "variable 'i' is accessed from within inner class, needs to be declared final". How can I get around this? Here is what I got String getValuesPressed(){ for(int i = 0; i < buttonList.length; i++){ buttonList[i].setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if(i == 0){//error

JS实现简易计算器的7种方法

拈花ヽ惹草 提交于 2020-01-03 10:59:09
先放图(好吧比较挫) 方法一:最容易版 <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8" /> <title>简易计算器</title> <style> body { background-color: #eee; } #calculator { margin: 100px 0 0 150px; } </style> </head> <body> <!-- 简易计算器 --> <div id="calculator"> <p> <input type="text" class="formerInput" value="1" /> <span class="sign">+</span> <input type="text" class="laterInput" value="1" /> <span>=</span> <span class="resultOutput">2</span> </p> <p> <input type="button" value="+" onclick="addHandler();" /> <input type="button" value="-" onclick="subtractHandler();" /> <input type="button" value="×"