Questions tagged [onclick]

An event which occurs when user clicked an object. It is a combination of two events, that is, "onmousedown" and "onmouseup".

Tag Usage

This tag is used frequently on questions surrounding Javascript event handling. It is worth noting that virtually every conceivable question has been asked on this topic so before you hit that post your question button, have you had a quick look to see if your question has already been covered?

14616 questions
114
votes
7 answers

HTML anchor tag with Javascript onclick event

On using Google I found that they are using onclick events in anchor tags. In more option in google header part, it looks like normal a tag, but onclicking it doesn't get redirected but opened a menu. Normally when using
smartkid
  • 1,499
  • 3
  • 14
  • 23
114
votes
9 answers

Execute PHP function with onclick

I am searching for a simple solution to call a PHP function only when a-tag is clicked. PHP: function removeday() { ... } HTML: Delete UPDATE: the html and PHP code are in the same PHP file
Mike
  • 3,200
  • 5
  • 22
  • 33
110
votes
8 answers

$(document).click() not working correctly on iPhone. jquery

This function works perfectly on IE, Firefox and Chrome but when on the iPhone, it will only work when clicking on a . Clicking on the page (anywhere but on a img) wont fire the event. $(document).ready(function () { …
Garrows
  • 3,031
  • 3
  • 25
  • 21
106
votes
6 answers

how to pass this element to javascript onclick function and add a class to that clicked element

I had an html navigation code as below function Data(string) { //1. get some data from server according to month year etc., //2. unactive all the remaining li's and make the current clicked element active by adding "active" class to the…
Shiva Krishna Bavandla
  • 25,548
  • 75
  • 193
  • 313
97
votes
10 answers

Get the contents of a table row with a button click

I need to extract the details of each column in my table. For example, column "Name/Nr.". The table contains a number of addresses The very last column of each row has a button that lets a user choose a listed address. Problem: My code only picks…
chuckfinley
  • 2,577
  • 10
  • 32
  • 42
92
votes
4 answers

javascript get x and y coordinates on mouse click

I have a little div tag that when I click on it (onClick event), it will run the printMousePos() function. These are the HTML tags:
Bryce Hahn
  • 1,585
  • 4
  • 16
  • 26
91
votes
5 answers

onclick or inline script isn't working in extension

This seems to be the easiest thing to do, but it's just not working. In a normal browser the .html and .js files works perfectly, but in the Chrome/Firefox extension the onClick function is not performing what it's supposed to do. .js file: function…
84
votes
9 answers

OnClick vs OnClientClick for an asp:CheckBox?

Does anyone know why a client-side javascript handler for asp:CheckBox needs to be an OnClick="" attribute rather than an OnClientClick="" attribute, as for asp:Button? For example, this works:
Stobor
  • 44,246
  • 6
  • 66
  • 69
83
votes
9 answers

android View with View.GONE still receives onTouch and onClick

This is confusing me: As far as I have read, a view with setVisibility(View.GONE); should not receive any more touch- or click events. My layout has two parts, which will be visible or gone so that only one of them is visible and usable at a time…
ShadowMare
  • 2,087
  • 2
  • 25
  • 27
83
votes
19 answers

Changing button text onclick

When I click on myButton1 button, I want the value to change to Close Curtain from Open Curtain.HTML: Javascript: function change(); { …
Anthony Do
  • 1,409
  • 4
  • 18
  • 19
82
votes
5 answers

How to switch to new window in Selenium for Python?

I am working on selenium automation project using Python. I am facing an issue, which is handling multiple browser windows. Scenario is as follows. When I click a link on the home page, a new window opens. In the newly opened window I cannot perform…
Sandeep Raveendran
  • 821
  • 1
  • 7
  • 3
77
votes
15 answers

onClick not triggered on LinearLayout with child

I've got a custom LinearLayout with a smaller TextView child. I'd like to be able to click the area not covered by the TextView, so I set clickable=true and an onclicklistener to the LinearLayout, but onClick is not triggered. If I set the onclick…
jul
  • 36,404
  • 64
  • 191
  • 318
75
votes
13 answers

jQuery function not binding to newly added dom elements

Here's index.html: