javascript - Is there a way to detect a click anywhere on a page except for a certain region? -


This is my problem, I am preparing a website that lets you click on that list to select a specific item Using the OnClick attribute allows me to be able to deselect the item by clicking anywhere on the page. I changed my code to & lt; Body onClick = "unselected ()" & gt; , but again if I click anywhere on the page, it cancels my item (even when I click to choose it for the first time!).

So is there a way to find out that the user has clicked somewhere else on my list in the list?

Thank you very much.

EDIT: I tried on Blur and with the handleClick mixed result when I click on the item that I want to choose, then select it and uncheck it immediately by selecting it.

Onblur is not going to cut it because it is not a standard HTML input element.

You want to see that this when the onclick event is called. If this refers to an item in your list, you can select the item in the list. If it is referenced outside of the list, deselect all items in your list.

The code can look like this:

  click the function handles (evt) {if (This.getAttribute ('isListItem')) {// Highlight} and { // highlighting} evt.preventDefault (); }  

The use of this code depends on keeping an attribute on HTML that the element is a list item. You would like to prevent the incident from promoting any sub-elements. I'm not 100% sure that this is necessary, but often because this event promotes the element in which your list item is included.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -