HTML结构
<iframe src="#" scrolling="no" id="gallery-frame">
<div class="gv_filmstrip">
<div class="gv_frame">
<div class="gv_thumbnail current">
<img src="images/grandstand-padang-right/1.jpg">
</div></div>
<div class="gv_frame">
<div class="gv_thumbnail">
<img src="images/grandstand-padang-right/2.jpg">
</div></div>
<div class="gv_frame">
<div class="gv_thumbnail">
<img src="images/grandstand-padang-right/3.jpg">
</div></div>
</div>
<div class="gv_panel"><img src="images/grandstand-padang-right/1.jpg"></div>
<div class="gv_panel"><img src="images/grandstand-padang-right/2.jpg"></div>
<div class="gv_panel"><img src="images/grandstand-padang-right/3.jpg"></div>
</iframe>
我想要的是什么?
我想访问课程gv_frame
并在其上放置一个onclick事件..在onclick事件中,我需要在img
gv_panel
的宽度和高度
我试过的脚本..
$("#gallery-frame").contents().find("gv_frame").click(function(){
alert("aaa"); // I am not getting the alert
});
第二次尝试
var width = $(".gv_panel img").width();
var height = $(".gv_panel img").height();
alert("width:"+width+" and height :"+height); // alert is null here
答案 0 :(得分:0)
你有错别字。移除contents()
并向您的班级选择器添加.
。
$("#gallery-frame").find(".gv_frame").click(function(){
alert("aaa"); // I am not getting the alert
});