How do I run javascript function from text like [some text]

I want to run a javascript function from text like [some text].  I can do it from a button and hyper link as shown below. THanks.

<a href="javascript:showGRID()"><font face="Arial" size="2">Click here to show grid.</font></a>
 
 
<INPUT  id=collateral onclick=showGRID(); type=button value="Show Grid" name=showGrid tabindex="99">

Open in new window

doindataAsked:
Who is Participating?
 
LordOfPortsConnect With a Mentor Commented:
One option would be to enclose the text with SPAN tags, e.g.:
<span onclick="alert('Text clicked');">[some text]</span>

Open in new window

0
 
JasonChandlerCommented:
Hi there this should do it:
<p onclick="ShowGrid();"> <ul>Your text here</ul> </p>

However you should add a stype to the <p> tag to add a hand cursor to the text.
See my code snippet

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
 
<script type="text/javascript">
function ShowGrid(){
 
}
</script>
<style type="text/css">
<!--
.pJava {
	cursor: help;
	text-decoration: underline;
}
-->
</style>
</head>
 
<body>
 
<a href="javascript:showGRID()"><font face="Arial" size="2">Click here to show grid.</font></a>
 
 
<p class="pJava" onclick="showGRID()"> Your text here </p>
</body>
</html>

Open in new window

0
 
JasonChandlerCommented:
Sorry I made a mistake..igno the <ul> tags in my reply. The Code snippet is ok. This is one way to do it.
0
 
doindataAuthor Commented:
Thanks, I ended up using the  tag but I will look at  as well.  
0
All Courses

From novice to tech pro — start learning today.