Link to home
Start Free TrialLog in
Avatar of Brad Bansner
Brad Bansner

asked on

make entire div a link?

Can I make a click anywhere inside the boundaries of a DIV a link? Thank you!
<script language="javascript" type="text/javascript">
	$(function(){
		$('#enclosingbox').click(function(){
			window.location.href='my page.htm';
		});
	});
</script>

<div id="enclosingbox">
(a whole bunch of HTML code)
</div>

Open in new window

Avatar of leakim971
leakim971
Flag of Guadeloupe image

should be the case here...
Avatar of Brad Bansner
Brad Bansner

ASKER

OK, not working though:

http://www.lifespanfitness.com/products_home_treadmills.asp

I want to be able to click the text:


Ready to use in minutes. No assembly required. Folds to 11" thin to store under a bed or in a closet. Ideal for occasional light walking.

And that links as well?
<script language="javascript" type="text/javascript">
	$(function(){
		$('#TR100_treadmill').click(function(){
			window.location.href='TR100_treadmill.asp';
		});
	});
</script>


	<div id="TR100_treadmill">
		<div><img src="art/px_trans.gif" width="1" height="12" border="0" alt="" /></div>
		<h5>$699</h5>
		<div><img src="art/px_trans.gif" width="1" height="6" border="0" alt="" /></div>
		<p>Free Shipping or<br />
			Concierge Service</p>
		<div><img src="art/px_trans.gif" width="120" height="1" border="0" alt="" /></div>
	</div>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ah, you are correct. I didn't have it enclosing the text the way I thought. Thanks for taking a look.
if you add a class to your text :

<p class="class_TR100_treadmill">Ready to use in minutes. No assembly required. Folds to 11" thin to store under a bed or in a closet. Ideal for occasional light walking.</p>

Open in new window


you may use (don't miss the DOT selector before class) :
		$('#TR100_treadmill,.class_TR100_treadmill').click(function(){
			window.location.href='TR100_treadmill.asp';
		});

Open in new window