Fire click event
Fire click event
Hello,
I'm searching for a way to fire a click event on a href.
I've searched the web but can't find a working solution.
My test code:
-
<!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>Test</title>
<!-- load jquery -->
<script src="jquery.js" type="text/javascript"></script>
</head>
<body>
<a href="downloads/portfolio.pdf" id="Test" name="Test">Test</a>
<script type="text/javascript">
$(document).ready(function() {
alert('hi');
//Click the hyperlink
[b] $('#Test').fireEvent('click');[/b]
});
</script>
</body>
</html>
I've tried the following codes but the all didn't work:
$('#Test').trigger('click');
$('#Test').click();
and:
$('#Test').fireEvent('click')
Can anyone help me with this?
Thanks!