Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 图像上的Ajax函数_Jquery_Ajax_Thumbnails - Fatal编程技术网

Jquery 图像上的Ajax函数

Jquery 图像上的Ajax函数,jquery,ajax,thumbnails,Jquery,Ajax,Thumbnails,我想在图像上启动一个函数。 我将JQueryThumbGallery与lightbox一起使用,并希望检索图像id 我的代码是 <div class='thumbHolder' **data-id="MY-ID"** data-title="<?php echo '<span class=\'io_home\'>'.$row['io'].'</span><br /> '.$row['first_name'].' '.$row['last_name'

我想在图像上启动一个函数。 我将JQueryThumbGallery与lightbox一起使用,并希望检索图像id

我的代码是

<div class='thumbHolder' **data-id="MY-ID"** data-title="<?php echo '<span class=\'io_home\'>'.$row['io'].'</span><br /> '.$row['first_name'].' '.$row['last_name'].'<br/><span class=\'voti_home\'>'.$row['tot_voti'].' VOTI</span>'; ?>">
  <a rel="prettyPhoto[ajax]" href="index.php/image/view_image?ajax=true&width=700px&height=450px&id=<?php echo $row['id']; ?>" >
  <img class="thumb_hidden" src="<?php echo base_url().'upload/concorso1/thumb/'.$row['url']; ?>" width="151" height="120" alt="<?php echo $row['first_name'].' '.$row['last_name']; ?>" />
                                </a>

                            </div>
我需要从打开的图像中检索ID(overThumb函数)。我已经试着设置data-id-I和data-id-j,但我还没有了解应该如何使用它们。你能帮我吗

链接到脚本

谢谢
fc

更改您的PHP代码,以如下方式呈现img标记标记(仅HTML!未连接任何函数)


现在使用一些javascript

<script type="text/javascript">
 $(function(){
   $("img.thumb_hidden").mouseover(function() {
       var ourImg=$(this);
       var urlOfImage=ourImg.attr("href");
       var idOfImage=ourImg.attr("id");
       //let's get the HTML5 data attribute as well
       var myCustomVal=ourImg.data("myAttr");
       //Now use these to make ajax call as necessary
   });    
 });
</script>

$(函数(){
$(“img.thumb\u隐藏”).mouseover(函数(){
var ourImg=$(本);
var urlOfImage=ourImg.attr(“href”);
变量idOfImage=ourImg.attr(“id”);
//让我们也来看看HTML5的数据属性
var myCustomVal=ourImg.data(“myAttr”);
//现在,根据需要使用这些命令进行ajax调用
});    
});
<img class="thumb_hidden" src="Somepath/someimage.jpg" 
               data-myAttr="my custom val" id="someUniqueID" alt="some text" />
<script type="text/javascript">
 $(function(){
   $("img.thumb_hidden").mouseover(function() {
       var ourImg=$(this);
       var urlOfImage=ourImg.attr("href");
       var idOfImage=ourImg.attr("id");
       //let's get the HTML5 data attribute as well
       var myCustomVal=ourImg.data("myAttr");
       //Now use these to make ajax call as necessary
   });    
 });
</script>