onclick

How to hide div by onclick using javascript?

江枫思渺然 提交于 2019-12-01 21:09:00
问题 I have used a javascript to show div by onclick but when i click outside div i want to hide the div. How to do it in javascript? i'm using javascript code.. <a href="javascript:;" onClick="toggle('one');"> function toggle(one) { var o=document.getElementById(one); o.style.display=(o.style.display=='none')?'block':'none'; } 回答1: HTML <a href="#" onclick="toggle(event, 'box');">show/hide</a> Javascript // click on the div function toggle( e, id ) { var el = document.getElementById(id); el.style

Binding click event handlers in a loop causing problems in jQuery

血红的双手。 提交于 2019-12-01 20:50:43
I am trying to run the following code: I pass parameter to a function, but it always has the value of the last object run through the loop. I read some articles about it on stackoverflow, but I couldn't find out how to make it run in my solution. The object is a JSON object returned from the server. All it's values are correct. for(var i = 0;i<parents.length;i++){ var row = $(document.createElement("tr")); var colName = $(document.createElement("td")); var aDisplayCol = $(document.createElement("a")); var parentId = parents[i]['PARENT_ID']; aDisplayCol.attr("href","#").html(parents[i]['NAME'])

No toast shown when item clicked RecyclerView

社会主义新天地 提交于 2019-12-01 20:28:18
Ok, I know, probably someone has already asked this question. I have already found a possible solution for my problem on this link . But, for an unknown reason, that solution doesn't work for me. I want to display a Toast when an item (a CardView ) is clicked inside a RecyclerView . This Toast must show me the position of the item clicked. When I click on a CardView I see the ripple - so that means that the card is clicked - but unfortunately, I don't see any toast. Can someone explain me why? Thanks in advance. This is my Adapter: public class MainRecyclerViewAdapter extends RecyclerView

click on a div with regular javascript

心已入冬 提交于 2019-12-01 19:54:43
jquery attaches a click method on even things that aren't typically clickable like a DIV. this can be great because some things respond to that. How can i "click" on any old regular DIV using plain old javascript without Jquery? what i am trying to do is trigger clicking on the area where the user can post in Jquery. I'm using a chrome extension that can run some javascript on a hotkey. I wrote a jquery version var x = $('div[guidedhelpid="sharebox"]'); x.click(); which works fine, other than it seems that the jquery library only loads about 1/4 of the time. not sure why, so i figured i'd try

Disabled Text Input with onclick

…衆ロ難τιáo~ 提交于 2019-12-01 19:50:43
I need a way of capturing onclick, for a text input that is disabled. I would prefer not to use jQuery, but if there was no javascript alternative, would use it. Thanks in advance EDIT: I have tried simply adding an onclick="" to a disabled text field, which did not work. Is there any way to do it without jquery? Thanks How about delegation events to parent elements like here ? <span style="position:relative;" onClick="event.target.value='clicked';"> <input type="text" disabled "/> </span> If my answer is acceptable please comment it and I'll make an explanation. You are probably lookinf for

Redux Store以及数据流

北战南征 提交于 2019-12-01 18:57:10
Store 在前面的章节中,我们定义了代表“发生了什么”的事实的actions以及根据这些动作更新状态的Reducer。 Store是将他们聚集在一起的对象。Store有以下责任: 持有应用程序状态; 允许通过getState()访问状态; 允许状态通过dispatch(action)更新; 通过订阅注册subscribe(listener); 通过subscribe(listener)返回的函数来处理注销监听器。 重要的是要注意,你将只有一个store在Redux应用程序中。当你想拆分你的数据处理逻辑时,你将使用reducer组合而不是许多store。 如果您有reducer,创建store很容易。在上一节中,我们使用了combineReducers()将多个reducer合并为一个。我们现在将其导入,并将其传递给createStore()。 123 import { createStore } from 'redux'import todoApp from './reducers'const store = createStore(todoApp) 您可以选择指定初始状态作为createStore()的第二个参数。这对于保证客户端的状态与服务器上运行的Redux应用程序的状态相匹配非常有用。 1 const store = createStore(todoApp, window

How to hide div by onclick using javascript?

 ̄綄美尐妖づ 提交于 2019-12-01 18:48:44
I have used a javascript to show div by onclick but when i click outside div i want to hide the div. How to do it in javascript? i'm using javascript code.. <a href="javascript:;" onClick="toggle('one');"> function toggle(one) { var o=document.getElementById(one); o.style.display=(o.style.display=='none')?'block':'none'; } HTML <a href="#" onclick="toggle(event, 'box');">show/hide</a> Javascript // click on the div function toggle( e, id ) { var el = document.getElementById(id); el.style.display = ( el.style.display == 'none' ) ? 'block' : 'none'; // save it for hiding toggle.el = el; // stop

JavaScript Show/Hide as Filters to list of divs

点点圈 提交于 2019-12-01 18:40:23
Looking to create Javascript that acts like a filter on a list of divs. For instance, here's the intended markup... <a href="#" onclick="">Filter Item 1</a> <a href="#" onclick="">Filter Item 2</a> <a href="#" onclick="">Filter Item 3</a> <a href="#" onclick="">Filter Item 4</a> <a href="#" onclick="">Filter Item 5</a> <div class="1">Item 1</div> <div class="1">Item 1</div> <div class="2">Item 2</div> <div class="3">Item 3</div> <div class="1">Item 1</div> <div class="4">Item 4</div> <div class="4">Item 4</div> <div class="1">Item 1</div> <div class="5">Item 5</div> I want to be able to click

Android cannot find method from button's onClick in ListView Row

梦想的初衷 提交于 2019-12-01 18:24:53
I have a ListView populated from a custom adapter. Each row has 1 button in it. In the xml the button has the onClick attribute passed. I have only the xml, not any OnClickListeners set. Also note that the public void myMethod (View v) exists in my CustomActivity. I get the following exception 10-02 03:01:46.463: E/AndroidRuntime(26857): java.lang.IllegalStateException: Could not find a method myClickHandler(View) in the activity class **android.app.Application** for onClick handler on view class android.widget.Button with id 'myButton' Method in Activity: public void myClickHandler(View v) {

Calling PHP scripts from Javascript without leaving current page

人盡茶涼 提交于 2019-12-01 17:46:02
问题 I'm having some trouble calling PHP scripts from Javascript without leaving the current HTML page (if it is at all possible). I understand it is possible using AJAX, although is it possible using Javascript alone? Context:- I want my page to perform a short animation using Javascript (using onclick), then immediately call a PHP script to insert data into a MySQL database - all without leaving the page so it does not inhibit the animation. The animation part I can do and the inserting the data