My question is same as this one
I also faced the same problem which is href
not triggered for event 'clicked'
.Then I changed to alt
and element is span
. Here is my code
<li><h2><span id='aa' alt="#inbox"><span>Inbox</span></span></h2></li>
This line is my 2nd child of ul
. I want to trigger/click this line when the page is loaded.
But I want to know how to trigger this span's(#aa) click event.Following codes are tried.but not worked.
first try:
var href = $('#aa').attr('alt');
window.location.href =href; // this gave me 404 error
2nd try:
$('#aa').trigger("click") // this has no change
Edit a function will be executed when the above mentioned li>span is clicked. I want that li's span be clicked automatically when the page has loaded. this question 's answers say some problems when <a href>
is used.Therefore, I used span
tag instead. I use jQuery 1.6