<?php if(isset($_SESSION['cnt'])&&($_SESSION['cnt'] == 5) ){
$_SESSION['cnt'] = 0;
?>
<script>
//$("#fb_login").trigger('click');
//$('#fb_login').click();
$("#fb_login").click(function(){
$("#fb_login").colorbox({width:"300px", height:"200px", inline:true, href:"#loginask_iframe"});
});
</script>
<?php } ?>
<a href="#" id="fb_login"></a>
<div style='display:none' class="loginask_iframe_container">
<div id="loginask_iframe">
test
</div>
</div>
i can't get the click function to trigger when the $_SESSION['cnt'] == 5
.
any ideas what i am doing wrong?
thanks
<script type="text/javascript">
// Here you define the click.
$("#fb_login").click(function(){
$("#fb_login").colorbox({width:"300px", height:"200px", inline:true, href:"#loginask_iframe"});
});
// Here you call the click.
$("#fb_login").click();
</script>
Is this what you're looking for?
$("#fb_login").trigger('click');
This may be a case of the click function being defined before the anchor is created. Try wrapping the click binding in $(document).ready( ...
<script>
function triggerLoginColorBox() {
$("#fb_login").colorbox({
width: "300px",
height: "200px",
inline: true,
href: "#loginask_iframe"
});
}
$("#fb_login").click(function(){triggerLoginColorBox();});
<?php
if (isset($_SESSION['cnt']) && ($_SESSION['cnt'] == 5) ){
$_SESSION['cnt'] = 0;
echo "triggerLoginColorBox();";
}
?>
</script>