Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

span with onclick event inside a tag

Tags:

html

css

Sample code

<a href="page" style="text-decoration:none;display:block;">     <span onclick="hide()">Hide me</span> </a> 

Since the a tag is over the span is not possible to click it. I try z-index but that didnt work

like image 485
Ben Avatar asked May 02 '12 11:05

Ben


2 Answers

<a href="http://the.url.com/page.html">     <span onclick="hide(); return false">Hide me</span> </a> 

This is the easiest solution.

like image 134
Mark Avatar answered Oct 01 '22 22:10

Mark


When you click on hide me, both a and span clicks are triggering. Since the page is redirecting to another, you cannot see the working of hide()

You can see this for more clarification

http://jsfiddle.net/jzn82/

like image 24
Nauphal Avatar answered Oct 01 '22 21:10

Nauphal