Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/69.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中选择同级的内容_Jquery_Html_Attributes_Fancybox_Siblings - Fatal编程技术网

在jQuery中选择同级的内容

在jQuery中选择同级的内容,jquery,html,attributes,fancybox,siblings,Jquery,Html,Attributes,Fancybox,Siblings,我试图获取jQuery中某个链接的同级的值,但我不确定如何选择它。这是我的HTML代码 <figure> <a class="figure" href="http://wbond.net/sublime_packages/img/package_control/install_package.png"><img src="http://wbond.net/sublime_packages/img/package_control/install_package

我试图获取jQuery中某个链接的同级的值,但我不确定如何选择它。这是我的HTML代码

<figure>
    <a class="figure" href="http://wbond.net/sublime_packages/img/package_control/install_package.png"><img src="http://wbond.net/sublime_packages/img/package_control/install_package.png" title="Something"></a>
    <figcaption>
        Great Picture Description. Original by <a href="http://www.example.com/">Random person</a>
    </figcaption>
</figure>
感谢您的支持

要回答您的标题(但不是您的问题),请选择以下选项:


我假设您希望使用
figcaption
的内容作为fancybox
标题
。。。。因此,对于上面相同的
html
,对于fancyboxv2.x请尝试以下脚本:

<script type="text/javascript">
var newCaption;
$(document).ready(function() {
 $(".figure").fancybox({
  afterLoad: function(){
   newCaption = $(this.element).next('figcaption').html();
   this.title = newCaption
  }
 }); // fancybox
}); // ready
</script>

我不明白你的问题<代码>figcaption位于
图中。你的问题毫无意义。请修改。我假设您想使用
figcaption
的内容作为fancybox的标题,不是吗?什么版本的fancybox?@JFK是最新版本,是的,我说的你是对的:)!
var content = $('figure figcaption').html();
alert(content);​
$('.figure ~ figcaption').
<script type="text/javascript">
var newCaption;
$(document).ready(function() {
 $(".figure").fancybox({
  afterLoad: function(){
   newCaption = $(this.element).next('figcaption').html();
   this.title = newCaption
  }
 }); // fancybox
}); // ready
</script>
helpers: {
 title : {
  type : 'inside'
 }
}