简体   繁体   中英

div click resize iframe or underlying div?

i'm not getting a response on a div click just need to know what i'm doing wrong http://jsfiddle.net/7nF2t/76/ thanks

<div id="click"><br></div>

$('#click').click(function(){
  alert('yes');
});

You need to make sure the document is ready before adding your event, eg :

 $(document).ready(function() {
   $('#click').click(function() { alert('yes'); }
 });

Damnd, didn't see jsfiddle. xdazz is right.

You are using .onclick in your jsfiddle, use .click instead.

The demo.

First if this is jQuery you have to use .click as many guys said. AND #alpha isn't a CLASS it's an ID i have changed your CSS, script, and HTML here: http://jsfiddle.net/7nF2t/89/

<div id="alpha" class="alpha">
    <iframe id="iframe" src="http://time.is"></iframe>
</div>
<div id="click"><br></div>​

<script>
$(document).ready(function() {
    $('#click').click(function(){
      alert('yes');
      $('#alpha').removeClass('alpha').addClass('alphas');
     });
});
</script>​

#click {
    z-index:2;
    margin-top:-200px;
    height:200px;
    width:200px;
    background-color:#888;
    opacity:0.48;
    filter:alpha(opacity=48);
}
.alpha {
  -webkit-transition: all 0.3s ease-out; 
     -moz-transition: all 0.3s ease-out; 
       -o-transition: all 0.3s ease-out; 
          transition: all 0.3s ease-out; 

    -moz-transform:scale(0.25);
    -moz-transform-origin:0 0;
    -o-transform:scale(0.25);
    -o-transform-origin:0 0;
    -webkit-transform:scale(0.25);
    -webkit-transform-origin:0 0 
}

.alphas {
    opacity:0.38;
    filter:alpha(opacity=38);

    -webkit-transform: scale(1.5);
       -moz-transform: scale(1.5);
        -ms-transform: scale(1.5);
         -o-transform: scale(1.5);
            transform: scale(1.5);
}

​

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM