Try switching the ordering:
if(newLdrshipMsg) {
$('#leadershipMsgId').click( function() {
showHideLeadershipMsg
(curMessageNum,'leadershipMsgCk');
});
$('#leadershipMsgId').click();
}
The click(...) defines what happens when you click it. It doesn't
actually perform the click.
The click() performs the click.
On Apr 23, 5:38 am, vmrao <[email protected]> wrote:
> I have a link as follows.
>
> <a href="march2009.html" onclick="return hs.htmlExpand(this,
> {contentId: 'highslide-html-1', objectWidth: 600, objectHeight: 510,
> width: 600})" id="leadershipMsgId" class="highslide whiteul">Message</
> a>
>
> In jQuery, I would like to automatically invoke a click event on the
> above link (calls htmlExpand function) based on a condition and also I
> would like to call another function (showHideLeadershipMsg) after the
> link is invoked.
>
> The following code does not work properly.
>
> if(newLdrshipMsg) {
> $('#leadershipMsgId').click(); //works
> $('#leadershipMsgId').click( function() {
> showHideLeadershipMsg(curMessageNum,'leadershipMsgCk'); //not
> getting called
> });
>
> }
>
> What am I missing ?