Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How to use Onclick on text

Posted on 2013-12-06
4
240 Views
Last Modified: 2013-12-06
Hi!

Have this code line:

<td class="rapport1_del5" align="left">
<a href="#" target="_self"> <img src="../images/skriver.png" TYPE="button" align="left" onClick="window.print()" /> Printer </a></td>

Open in new window


When the user clicks on the picture, its running -> windows.print()

But i want the same to happend when user only click on the text -> Printer

How do i do this ?
0
Comment
Question by:team2005
  • 2
4 Comments
 
LVL 25

Accepted Solution

by:
Lee Savidge earned 350 total points
ID: 39700439
<td class="rapport1_del5" align="left">
<a href="#" onClick="window.print()"> <img src="../images/skriver.png" TYPE="button" align="left" /> Printer </a></td>

Open in new window

0
 
LVL 30

Assisted Solution

by:Alexandre Simões
Alexandre Simões earned 150 total points
ID: 39700440
Put the onClick event handler on the <a>
<a href="#" target="_self" onClick="window.print()"> <img src="../images/skriver.png" TYPE="button" align="left" /> Printer </a>

Open in new window

0
 
LVL 30

Expert Comment

by:Alexandre Simões
ID: 39700442
Although if you're not actually using the <a> for nothing I would suggest to use a div or a span.

I don't like to see the # at the end of the URLs and that's what happens when you click that Printer link.
0
 
LVL 2

Author Closing Comment

by:team2005
ID: 39700580
thanks
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question