The .trigger()
function will only cause the handler methods that you attached with jQuery to execute. It will not cause the normal behavior of the <a>
elements to execute. That is, it will not load the <iframe>
.
You could use e.preventDefault()
to prevent the <a>
element from performing its default behavior, and add code that performs it explicitly. That way, it will execute both when it is clicked and when .trigger()
is called.
In your case, you would need to set the src
property of the <iframe>
.
Try changing the event handler to this:
$("#selection a").click(function(e) {
var $a = $(this);
e.preventDefault();
$a.parent().addClass('selected').siblings().removeClass('selected');
$('iframe[name=iframeload]').prop('src', $a.attr('href'));
$("#debug").text( $a.attr("href") +" was just clicked");
});